diff --git a/sdk/authorization/azure-mgmt-authorization/CHANGELOG.md b/sdk/authorization/azure-mgmt-authorization/CHANGELOG.md index 837b21fc0770..7dcf5af3fbab 100644 --- a/sdk/authorization/azure-mgmt-authorization/CHANGELOG.md +++ b/sdk/authorization/azure-mgmt-authorization/CHANGELOG.md @@ -1,5 +1,241 @@ # Release History +## 5.0.0b1 (2025-07-16) + +### Features Added + + - Client `AuthorizationManagementClient` added operation group `classic_administrators` + - Client `AuthorizationManagementClient` added operation group `global_administrator` + - Client `AuthorizationManagementClient` added operation group `deny_assignments` + - Client `AuthorizationManagementClient` added operation group `provider_operations_metadata` + - Client `AuthorizationManagementClient` added operation group `role_assignments` + - Client `AuthorizationManagementClient` added operation group `permissions` + - Client `AuthorizationManagementClient` added operation group `role_definitions` + - Client `AuthorizationManagementClient` added operation group `operations` + - Client `AuthorizationManagementClient` added operation group `access_review_history_definitions` + - Client `AuthorizationManagementClient` added operation group `access_review_history_definition` + - Client `AuthorizationManagementClient` added operation group `access_review_history_definition_instance` + - Client `AuthorizationManagementClient` added operation group `access_review_history_definition_instances` + - Client `AuthorizationManagementClient` added operation group `access_review_schedule_definitions` + - Client `AuthorizationManagementClient` added operation group `access_review_instances` + - Client `AuthorizationManagementClient` added operation group `access_review_instance` + - Client `AuthorizationManagementClient` added operation group `access_review_instance_decisions` + - Client `AuthorizationManagementClient` added operation group `access_review_instance_contacted_reviewers` + - Client `AuthorizationManagementClient` added operation group `access_review_default_settings` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_history_definitions` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_history_definition` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_history_definition_instance` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_history_definition_instances` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_schedule_definitions` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_instances` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_instance` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_instance_decisions` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_instance_contacted_reviewers` + - Client `AuthorizationManagementClient` added operation group `scope_access_review_default_settings` + - Client `AuthorizationManagementClient` added operation group `access_review_schedule_definitions_assigned_for_my_approval` + - Client `AuthorizationManagementClient` added operation group `access_review_instances_assigned_for_my_approval` + - Client `AuthorizationManagementClient` added operation group `access_review_instance_my_decisions` + - Client `AuthorizationManagementClient` added operation group `tenant_level_access_review_instance_contacted_reviewers` + - Client `AuthorizationManagementClient` added operation group `eligible_child_resources` + - Client `AuthorizationManagementClient` added operation group `role_assignment_schedules` + - Client `AuthorizationManagementClient` added operation group `role_assignment_schedule_instances` + - Client `AuthorizationManagementClient` added operation group `role_assignment_schedule_requests` + - Client `AuthorizationManagementClient` added operation group `role_eligibility_schedules` + - Client `AuthorizationManagementClient` added operation group `role_eligibility_schedule_instances` + - Client `AuthorizationManagementClient` added operation group `role_eligibility_schedule_requests` + - Client `AuthorizationManagementClient` added operation group `role_management_policies` + - Client `AuthorizationManagementClient` added operation group `role_management_policy_assignments` + - Added enum `AccessRecommendationType` + - Added enum `AccessReviewActorIdentityType` + - Added enum `AccessReviewApplyResult` + - Added model `AccessReviewContactedReviewer` + - Added model `AccessReviewContactedReviewerListResult` + - Added model `AccessReviewDecision` + - Added model `AccessReviewDecisionIdentity` + - Added model `AccessReviewDecisionInsight` + - Added model `AccessReviewDecisionInsightProperties` + - Added enum `AccessReviewDecisionInsightType` + - Added model `AccessReviewDecisionListResult` + - Added enum `AccessReviewDecisionPrincipalResourceMembershipType` + - Added model `AccessReviewDecisionProperties` + - Added model `AccessReviewDecisionServicePrincipalIdentity` + - Added model `AccessReviewDecisionUserIdentity` + - Added model `AccessReviewDecisionUserSignInInsightProperties` + - Added model `AccessReviewDefaultSettings` + - Added model `AccessReviewHistoryDefinition` + - Added model `AccessReviewHistoryDefinitionInstanceListResult` + - Added model `AccessReviewHistoryDefinitionListResult` + - Added model `AccessReviewHistoryDefinitionProperties` + - Added enum `AccessReviewHistoryDefinitionStatus` + - Added model `AccessReviewHistoryInstance` + - Added model `AccessReviewInstance` + - Added model `AccessReviewInstanceListResult` + - Added model `AccessReviewInstanceProperties` + - Added enum `AccessReviewInstanceReviewersType` + - Added enum `AccessReviewInstanceStatus` + - Added enum `AccessReviewRecurrencePatternType` + - Added enum `AccessReviewRecurrenceRangeType` + - Added enum `AccessReviewResult` + - Added model `AccessReviewReviewer` + - Added enum `AccessReviewReviewerType` + - Added model `AccessReviewScheduleDefinition` + - Added model `AccessReviewScheduleDefinitionListResult` + - Added model `AccessReviewScheduleDefinitionProperties` + - Added enum `AccessReviewScheduleDefinitionReviewersType` + - Added enum `AccessReviewScheduleDefinitionStatus` + - Added model `AccessReviewScheduleSettings` + - Added model `AccessReviewScope` + - Added enum `AccessReviewScopeAssignmentState` + - Added enum `AccessReviewScopePrincipalType` + - Added enum `ApprovalMode` + - Added model `ApprovalSettings` + - Added model `ApprovalStage` + - Added enum `AssignmentType` + - Added model `ClassicAdministrator` + - Added model `ClassicAdministratorListResult` + - Added enum `DecisionResourceType` + - Added enum `DecisionTargetType` + - Added enum `DefaultDecisionType` + - Added model `DenyAssignment` + - Added model `DenyAssignmentFilter` + - Added model `DenyAssignmentListResult` + - Added model `DenyAssignmentPermission` + - Added model `EligibleChildResource` + - Added model `EligibleChildResourcesListResult` + - Added enum `EnablementRules` + - Added model `ErrorAdditionalInfo` + - Added model `ErrorDefinition` + - Added model `ErrorDefinitionProperties` + - Added model `ErrorDetail` + - Added model `ErrorResponse` + - Added enum `ExcludedPrincipalTypes` + - Added model `ExpandedProperties` + - Added model `ExpandedPropertiesPrincipal` + - Added model `ExpandedPropertiesRoleDefinition` + - Added model `ExpandedPropertiesScope` + - Added enum `MemberType` + - Added enum `NotificationDeliveryMechanism` + - Added enum `NotificationLevel` + - Added model `Operation` + - Added model `OperationDisplay` + - Added model `OperationListResult` + - Added enum `PIMOnlyMode` + - Added model `PIMOnlyModeSettings` + - Added model `Permission` + - Added model `PermissionGetResult` + - Added model `PolicyAssignmentProperties` + - Added model `PolicyAssignmentPropertiesPolicy` + - Added model `PolicyAssignmentPropertiesRoleDefinition` + - Added model `PolicyAssignmentPropertiesScope` + - Added model `PolicyProperties` + - Added model `PolicyPropertiesScope` + - Added model `Principal` + - Added enum `PrincipalType` + - Added model `ProviderOperation` + - Added model `ProviderOperationsMetadata` + - Added model `ProviderOperationsMetadataListResult` + - Added enum `RecipientType` + - Added model `RecordAllDecisionsProperties` + - Added enum `RecordAllDecisionsResult` + - Added enum `RequestType` + - Added model `ResourceType` + - Added model `RoleAssignment` + - Added model `RoleAssignmentCreateParameters` + - Added model `RoleAssignmentFilter` + - Added model `RoleAssignmentListResult` + - Added model `RoleAssignmentSchedule` + - Added model `RoleAssignmentScheduleFilter` + - Added model `RoleAssignmentScheduleInstance` + - Added model `RoleAssignmentScheduleInstanceFilter` + - Added model `RoleAssignmentScheduleInstanceListResult` + - Added model `RoleAssignmentScheduleListResult` + - Added model `RoleAssignmentScheduleRequest` + - Added model `RoleAssignmentScheduleRequestFilter` + - Added model `RoleAssignmentScheduleRequestListResult` + - Added model `RoleAssignmentScheduleRequestPropertiesScheduleInfo` + - Added model `RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration` + - Added model `RoleAssignmentScheduleRequestPropertiesTicketInfo` + - Added model `RoleDefinition` + - Added model `RoleDefinitionFilter` + - Added model `RoleDefinitionListResult` + - Added model `RoleEligibilitySchedule` + - Added model `RoleEligibilityScheduleFilter` + - Added model `RoleEligibilityScheduleInstance` + - Added model `RoleEligibilityScheduleInstanceFilter` + - Added model `RoleEligibilityScheduleInstanceListResult` + - Added model `RoleEligibilityScheduleListResult` + - Added model `RoleEligibilityScheduleRequest` + - Added model `RoleEligibilityScheduleRequestFilter` + - Added model `RoleEligibilityScheduleRequestListResult` + - Added model `RoleEligibilityScheduleRequestPropertiesScheduleInfo` + - Added model `RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration` + - Added model `RoleEligibilityScheduleRequestPropertiesTicketInfo` + - Added model `RoleManagementPolicy` + - Added model `RoleManagementPolicyApprovalRule` + - Added model `RoleManagementPolicyAssignment` + - Added model `RoleManagementPolicyAssignmentListResult` + - Added model `RoleManagementPolicyAuthenticationContextRule` + - Added model `RoleManagementPolicyEnablementRule` + - Added model `RoleManagementPolicyExpirationRule` + - Added model `RoleManagementPolicyListResult` + - Added model `RoleManagementPolicyNotificationRule` + - Added model `RoleManagementPolicyPimOnlyModeRule` + - Added model `RoleManagementPolicyRule` + - Added model `RoleManagementPolicyRuleTarget` + - Added enum `RoleManagementPolicyRuleType` + - Added enum `Status` + - Added enum `Type` + - Added model `UserSet` + - Added enum `UserType` + - Added model `UsersOrServicePrincipalSet` + - Added model `ValidationResponse` + - Added model `ValidationResponseErrorInfo` + - Added model `AccessReviewDefaultSettingsOperations` + - Added model `AccessReviewHistoryDefinitionInstanceOperations` + - Added model `AccessReviewHistoryDefinitionInstancesOperations` + - Added model `AccessReviewHistoryDefinitionOperations` + - Added model `AccessReviewHistoryDefinitionsOperations` + - Added model `AccessReviewInstanceContactedReviewersOperations` + - Added model `AccessReviewInstanceDecisionsOperations` + - Added model `AccessReviewInstanceMyDecisionsOperations` + - Added model `AccessReviewInstanceOperations` + - Added model `AccessReviewInstancesAssignedForMyApprovalOperations` + - Added model `AccessReviewInstancesOperations` + - Added model `AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` + - Added model `AccessReviewScheduleDefinitionsOperations` + - Added model `ClassicAdministratorsOperations` + - Added model `DenyAssignmentsOperations` + - Added model `EligibleChildResourcesOperations` + - Added model `GlobalAdministratorOperations` + - Added model `Operations` + - Added model `PermissionsOperations` + - Added model `ProviderOperationsMetadataOperations` + - Added model `RoleAssignmentScheduleInstancesOperations` + - Added model `RoleAssignmentScheduleRequestsOperations` + - Added model `RoleAssignmentSchedulesOperations` + - Added model `RoleAssignmentsOperations` + - Added model `RoleDefinitionsOperations` + - Added model `RoleEligibilityScheduleInstancesOperations` + - Added model `RoleEligibilityScheduleRequestsOperations` + - Added model `RoleEligibilitySchedulesOperations` + - Added model `RoleManagementPoliciesOperations` + - Added model `RoleManagementPolicyAssignmentsOperations` + - Added model `ScopeAccessReviewDefaultSettingsOperations` + - Added model `ScopeAccessReviewHistoryDefinitionInstanceOperations` + - Added model `ScopeAccessReviewHistoryDefinitionInstancesOperations` + - Added model `ScopeAccessReviewHistoryDefinitionOperations` + - Added model `ScopeAccessReviewHistoryDefinitionsOperations` + - Added model `ScopeAccessReviewInstanceContactedReviewersOperations` + - Added model `ScopeAccessReviewInstanceDecisionsOperations` + - Added model `ScopeAccessReviewInstanceOperations` + - Added model `ScopeAccessReviewInstancesOperations` + - Added model `ScopeAccessReviewScheduleDefinitionsOperations` + - Added model `TenantLevelAccessReviewInstanceContactedReviewersOperations` + +### Breaking Changes + + - Method `AuthorizationManagementClient.__init__` inserted a `positional_or_keyword` parameter `subscription_id` + ## 4.0.0 (2023-07-21) ### Features Added diff --git a/sdk/authorization/azure-mgmt-authorization/MANIFEST.in b/sdk/authorization/azure-mgmt-authorization/MANIFEST.in index 70e792b11202..193202f7593a 100644 --- a/sdk/authorization/azure-mgmt-authorization/MANIFEST.in +++ b/sdk/authorization/azure-mgmt-authorization/MANIFEST.in @@ -1,4 +1,3 @@ -include _meta.json recursive-include tests *.py *.json recursive-include samples *.py *.md include *.md diff --git a/sdk/authorization/azure-mgmt-authorization/README.md b/sdk/authorization/azure-mgmt-authorization/README.md index 81250937be67..53aacadac98f 100644 --- a/sdk/authorization/azure-mgmt-authorization/README.md +++ b/sdk/authorization/azure-mgmt-authorization/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Authorization Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/authorization/azure-mgmt-authorization/_meta.json b/sdk/authorization/azure-mgmt-authorization/_meta.json deleted file mode 100644 index ca36520af982..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "1af2861030243b06ee35172c95899f4809eedfc7", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", - "use": [ - "@autorest/python@6.6.0", - "@autorest/modelerfour@4.24.3" - ], - "autorest_command": "autorest specification/authorization/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/authorization/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/_metadata.json b/sdk/authorization/azure-mgmt-authorization/_metadata.json new file mode 100644 index 000000000000..72a4047b3154 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/_metadata.json @@ -0,0 +1,11 @@ +{ + "commit": "7e14c91eef5e536d52471f60d648ed08aa9538b6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.35.0", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/authorization/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.35.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/authorization/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/__init__.py index 918a9284afb9..b493190a580c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/__init__.py @@ -5,16 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._authorization_management_client import AuthorizationManagementClient -__all__ = ['AuthorizationManagementClient'] +from typing import TYPE_CHECKING -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._authorization_management_client import AuthorizationManagementClient # type: ignore from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AuthorizationManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py index 381d561b2425..4d55f5351ab7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py @@ -1,1125 +1,435 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints +from . import models as _models from ._configuration import AuthorizationManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + AccessReviewDefaultSettingsOperations, + AccessReviewHistoryDefinitionInstanceOperations, + AccessReviewHistoryDefinitionInstancesOperations, + AccessReviewHistoryDefinitionOperations, + AccessReviewHistoryDefinitionsOperations, + AccessReviewInstanceContactedReviewersOperations, + AccessReviewInstanceDecisionsOperations, + AccessReviewInstanceMyDecisionsOperations, + AccessReviewInstanceOperations, + AccessReviewInstancesAssignedForMyApprovalOperations, + AccessReviewInstancesOperations, + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, + AccessReviewScheduleDefinitionsOperations, + AlertConfigurationsOperations, + AlertDefinitionsOperations, + AlertIncidentsOperations, + AlertOperationOperations, + AlertsOperations, + ClassicAdministratorsOperations, + DenyAssignmentsOperations, + EligibleChildResourcesOperations, + GlobalAdministratorOperations, + Operations, + PermissionsOperations, + ProviderOperationsMetadataOperations, + RoleAssignmentScheduleInstancesOperations, + RoleAssignmentScheduleRequestsOperations, + RoleAssignmentSchedulesOperations, + RoleAssignmentsOperations, + RoleDefinitionsOperations, + RoleEligibilityScheduleInstancesOperations, + RoleEligibilityScheduleRequestsOperations, + RoleEligibilitySchedulesOperations, + RoleManagementPoliciesOperations, + RoleManagementPolicyAssignmentsOperations, + ScopeAccessReviewDefaultSettingsOperations, + ScopeAccessReviewHistoryDefinitionInstanceOperations, + ScopeAccessReviewHistoryDefinitionInstancesOperations, + ScopeAccessReviewHistoryDefinitionOperations, + ScopeAccessReviewHistoryDefinitionsOperations, + ScopeAccessReviewInstanceContactedReviewersOperations, + ScopeAccessReviewInstanceDecisionsOperations, + ScopeAccessReviewInstanceOperations, + ScopeAccessReviewInstancesOperations, + ScopeAccessReviewScheduleDefinitionsOperations, + TenantLevelAccessReviewInstanceContactedReviewersOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass - -class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. - - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. +class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. + + :ivar classic_administrators: ClassicAdministratorsOperations operations + :vartype classic_administrators: + azure.mgmt.authorization.operations.ClassicAdministratorsOperations + :ivar global_administrator: GlobalAdministratorOperations operations + :vartype global_administrator: + azure.mgmt.authorization.operations.GlobalAdministratorOperations + :ivar deny_assignments: DenyAssignmentsOperations operations + :vartype deny_assignments: azure.mgmt.authorization.operations.DenyAssignmentsOperations + :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations + :vartype provider_operations_metadata: + azure.mgmt.authorization.operations.ProviderOperationsMetadataOperations + :ivar role_assignments: RoleAssignmentsOperations operations + :vartype role_assignments: azure.mgmt.authorization.operations.RoleAssignmentsOperations + :ivar permissions: PermissionsOperations operations + :vartype permissions: azure.mgmt.authorization.operations.PermissionsOperations + :ivar role_definitions: RoleDefinitionsOperations operations + :vartype role_definitions: azure.mgmt.authorization.operations.RoleDefinitionsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.authorization.operations.Operations + :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations + :vartype access_review_history_definitions: + azure.mgmt.authorization.operations.AccessReviewHistoryDefinitionsOperations + :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations + :vartype access_review_history_definition: + azure.mgmt.authorization.operations.AccessReviewHistoryDefinitionOperations + :ivar access_review_history_definition_instance: + AccessReviewHistoryDefinitionInstanceOperations operations + :vartype access_review_history_definition_instance: + azure.mgmt.authorization.operations.AccessReviewHistoryDefinitionInstanceOperations + :ivar access_review_history_definition_instances: + AccessReviewHistoryDefinitionInstancesOperations operations + :vartype access_review_history_definition_instances: + azure.mgmt.authorization.operations.AccessReviewHistoryDefinitionInstancesOperations + :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.operations.AccessReviewScheduleDefinitionsOperations + :ivar access_review_instances: AccessReviewInstancesOperations operations + :vartype access_review_instances: + azure.mgmt.authorization.operations.AccessReviewInstancesOperations + :ivar access_review_instance: AccessReviewInstanceOperations operations + :vartype access_review_instance: + azure.mgmt.authorization.operations.AccessReviewInstanceOperations + :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.operations.AccessReviewInstanceDecisionsOperations + :ivar access_review_instance_contacted_reviewers: + AccessReviewInstanceContactedReviewersOperations operations + :vartype access_review_instance_contacted_reviewers: + azure.mgmt.authorization.operations.AccessReviewInstanceContactedReviewersOperations + :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations + :vartype access_review_default_settings: + azure.mgmt.authorization.operations.AccessReviewDefaultSettingsOperations + :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations + operations + :vartype scope_access_review_history_definitions: + azure.mgmt.authorization.operations.ScopeAccessReviewHistoryDefinitionsOperations + :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations + operations + :vartype scope_access_review_history_definition: + azure.mgmt.authorization.operations.ScopeAccessReviewHistoryDefinitionOperations + :ivar scope_access_review_history_definition_instance: + ScopeAccessReviewHistoryDefinitionInstanceOperations operations + :vartype scope_access_review_history_definition_instance: + azure.mgmt.authorization.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations + :ivar scope_access_review_history_definition_instances: + ScopeAccessReviewHistoryDefinitionInstancesOperations operations + :vartype scope_access_review_history_definition_instances: + azure.mgmt.authorization.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations + :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations + operations + :vartype scope_access_review_schedule_definitions: + azure.mgmt.authorization.operations.ScopeAccessReviewScheduleDefinitionsOperations + :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations + :vartype scope_access_review_instances: + azure.mgmt.authorization.operations.ScopeAccessReviewInstancesOperations + :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations + :vartype scope_access_review_instance: + azure.mgmt.authorization.operations.ScopeAccessReviewInstanceOperations + :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations + operations + :vartype scope_access_review_instance_decisions: + azure.mgmt.authorization.operations.ScopeAccessReviewInstanceDecisionsOperations + :ivar scope_access_review_instance_contacted_reviewers: + ScopeAccessReviewInstanceContactedReviewersOperations operations + :vartype scope_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.operations.ScopeAccessReviewInstanceContactedReviewersOperations + :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations + operations + :vartype scope_access_review_default_settings: + azure.mgmt.authorization.operations.ScopeAccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.operations.AccessReviewInstanceMyDecisionsOperations + :ivar tenant_level_access_review_instance_contacted_reviewers: + TenantLevelAccessReviewInstanceContactedReviewersOperations operations + :vartype tenant_level_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations + :ivar eligible_child_resources: EligibleChildResourcesOperations operations + :vartype eligible_child_resources: + azure.mgmt.authorization.operations.EligibleChildResourcesOperations + :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations + :vartype role_assignment_schedules: + azure.mgmt.authorization.operations.RoleAssignmentSchedulesOperations + :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.operations.RoleAssignmentScheduleInstancesOperations + :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.operations.RoleAssignmentScheduleRequestsOperations + :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.operations.RoleEligibilityScheduleInstancesOperations + :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.operations.RoleEligibilityScheduleRequestsOperations + :ivar role_management_policies: RoleManagementPoliciesOperations operations + :vartype role_management_policies: + azure.mgmt.authorization.operations.RoleManagementPoliciesOperations + :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.operations.RoleManagementPolicyAssignmentsOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.authorization.operations.AlertsOperations + :ivar alert_configurations: AlertConfigurationsOperations operations + :vartype alert_configurations: + azure.mgmt.authorization.operations.AlertConfigurationsOperations + :ivar alert_definitions: AlertDefinitionsOperations operations + :vartype alert_definitions: azure.mgmt.authorization.operations.AlertDefinitionsOperations + :ivar alert_incidents: AlertIncidentsOperations operations + :vartype alert_incidents: azure.mgmt.authorization.operations.AlertIncidentsOperations + :ivar alert_operation: AlertOperationOperations operations + :vartype alert_operation: azure.mgmt.authorization.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-04-01' - _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'access_review_default_settings': '2021-12-01-preview', - 'access_review_history_definition': '2021-12-01-preview', - 'access_review_history_definition_instance': '2021-12-01-preview', - 'access_review_history_definition_instances': '2021-12-01-preview', - 'access_review_history_definitions': '2021-12-01-preview', - 'access_review_instance': '2021-12-01-preview', - 'access_review_instance_contacted_reviewers': '2021-12-01-preview', - 'access_review_instance_decisions': '2021-12-01-preview', - 'access_review_instance_my_decisions': '2021-12-01-preview', - 'access_review_instances': '2021-12-01-preview', - 'access_review_instances_assigned_for_my_approval': '2021-12-01-preview', - 'access_review_schedule_definitions': '2021-12-01-preview', - 'access_review_schedule_definitions_assigned_for_my_approval': '2021-12-01-preview', - 'classic_administrators': '2015-07-01', - 'eligible_child_resources': '2020-10-01', - 'global_administrator': '2015-07-01', - 'operations': '2021-12-01-preview', - 'role_assignment_approval': '2021-01-01-preview', - 'role_assignment_approval_step': '2021-01-01-preview', - 'role_assignment_approval_steps': '2021-01-01-preview', - 'role_assignment_metrics': '2019-08-01-preview', - 'role_assignment_schedule_instances': '2020-10-01', - 'role_assignment_schedule_requests': '2020-10-01', - 'role_assignment_schedules': '2020-10-01', - 'role_eligibility_schedule_instances': '2020-10-01', - 'role_eligibility_schedule_requests': '2020-10-01', - 'role_eligibility_schedules': '2020-10-01', - 'role_management_policies': '2020-10-01', - 'role_management_policy_assignments': '2020-10-01', - 'scope_access_review_default_settings': '2021-12-01-preview', - 'scope_access_review_history_definition': '2021-12-01-preview', - 'scope_access_review_history_definition_instance': '2021-12-01-preview', - 'scope_access_review_history_definition_instances': '2021-12-01-preview', - 'scope_access_review_history_definitions': '2021-12-01-preview', - 'scope_access_review_instance': '2021-12-01-preview', - 'scope_access_review_instance_contacted_reviewers': '2021-12-01-preview', - 'scope_access_review_instance_decisions': '2021-12-01-preview', - 'scope_access_review_instances': '2021-12-01-preview', - 'scope_access_review_schedule_definitions': '2021-12-01-preview', - 'scope_role_assignment_approval': '2021-01-01-preview', - 'scope_role_assignment_approval_step': '2021-01-01-preview', - 'scope_role_assignment_approval_steps': '2021-01-01-preview', - 'tenant_level_access_review_instance_contacted_reviewers': '2021-12-01-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - api_version: Optional[str]=None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, - **kwargs: Any - ): - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AuthorizationManagementClient, self).__init__( - api_version=api_version, - profile=profile + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = AuthorizationManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-06-01: :mod:`v2015_06_01.models` - * 2015-07-01: :mod:`v2015_07_01.models` - * 2018-01-01-preview: :mod:`v2018_01_01_preview.models` - * 2018-05-01-preview: :mod:`v2018_05_01_preview.models` - * 2018-07-01-preview: :mod:`v2018_07_01_preview.models` - * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` - * 2019-08-01-preview: :mod:`v2019_08_01_preview.models` - * 2020-04-01-preview: :mod:`v2020_04_01_preview.models` - * 2020-10-01: :mod:`v2020_10_01.models` - * 2020-10-01-preview: :mod:`v2020_10_01_preview.models` - * 2021-01-01-preview: :mod:`v2021_01_01_preview.models` - * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-12-01-preview: :mod:`v2021_12_01_preview.models` - * 2022-04-01: :mod:`v2022_04_01.models` - * 2022-04-01-preview: :mod:`v2022_04_01_preview.models` - * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - """ - if api_version == '2015-06-01': - from .v2015_06_01 import models - return models - elif api_version == '2015-07-01': - from .v2015_07_01 import models - return models - elif api_version == '2018-01-01-preview': - from .v2018_01_01_preview import models - return models - elif api_version == '2018-05-01-preview': - from .v2018_05_01_preview import models - return models - elif api_version == '2018-07-01-preview': - from .v2018_07_01_preview import models - return models - elif api_version == '2018-09-01-preview': - from .v2018_09_01_preview import models - return models - elif api_version == '2019-08-01-preview': - from .v2019_08_01_preview import models - return models - elif api_version == '2020-04-01-preview': - from .v2020_04_01_preview import models - return models - elif api_version == '2020-10-01': - from .v2020_10_01 import models - return models - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview import models - return models - elif api_version == '2021-01-01-preview': - from .v2021_01_01_preview import models - return models - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview import models - return models - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview import models - return models - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview import models - return models - elif api_version == '2022-04-01': - from .v2022_04_01 import models - return models - elif api_version == '2022-04-01-preview': - from .v2022_04_01_preview import models - return models - elif api_version == '2022-05-01-preview': - from .v2022_05_01_preview import models - return models - elif api_version == '2022-08-01-preview': - from .v2022_08_01_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def access_review_default_settings(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-12-01-preview: :class:`AccessReviewDefaultSettingsOperations` - """ - api_version = self._get_api_version('access_review_default_settings') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionOperations` - """ - api_version = self._get_api_version('access_review_history_definition') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewHistoryDefinitionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstanceOperations` - """ - api_version = self._get_api_version('access_review_history_definition_instance') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewHistoryDefinitionInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstancesOperations` - """ - api_version = self._get_api_version('access_review_history_definition_instances') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewHistoryDefinitionInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionsOperations` - """ - api_version = self._get_api_version('access_review_history_definitions') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewHistoryDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceOperations` - """ - api_version = self._get_api_version('access_review_instance') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('access_review_instance_contacted_reviewers') - if api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_decisions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - """ - api_version = self._get_api_version('access_review_instance_decisions') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_my_decisions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - """ - api_version = self._get_api_version('access_review_instance_my_decisions') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instances(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-07-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-12-01-preview: :class:`AccessReviewInstancesOperations` - """ - api_version = self._get_api_version('access_review_instances') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instances_assigned_for_my_approval(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-12-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - """ - api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_schedule_definitions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - """ - api_version = self._get_api_version('access_review_schedule_definitions') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_schedule_definitions_assigned_for_my_approval(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - """ - api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_configurations(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertConfigurationsOperations` - """ - api_version = self._get_api_version('alert_configurations') - if api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import AlertConfigurationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_configurations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_definitions(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertDefinitionsOperations` - """ - api_version = self._get_api_version('alert_definitions') - if api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import AlertDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_incidents(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertIncidentsOperations` - """ - api_version = self._get_api_version('alert_incidents') - if api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import AlertIncidentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_incidents'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_operation(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertOperationOperations` - """ - api_version = self._get_api_version('alert_operation') - if api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import AlertOperationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_operation'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertsOperations` - """ - api_version = self._get_api_version('alerts') - if api_version == '2022-08-01-preview': - from .v2022_08_01_preview.operations import AlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def classic_administrators(self): - """Instance depends on the API version: - - * 2015-06-01: :class:`ClassicAdministratorsOperations` - * 2015-07-01: :class:`ClassicAdministratorsOperations` - """ - api_version = self._get_api_version('classic_administrators') - if api_version == '2015-06-01': - from .v2015_06_01.operations import ClassicAdministratorsOperations as OperationClass - elif api_version == '2015-07-01': - from .v2015_07_01.operations import ClassicAdministratorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'classic_administrators'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def deny_assignments(self): - """Instance depends on the API version: - - * 2018-07-01-preview: :class:`DenyAssignmentsOperations` - * 2022-04-01: :class:`DenyAssignmentsOperations` - """ - api_version = self._get_api_version('deny_assignments') - if api_version == '2018-07-01-preview': - from .v2018_07_01_preview.operations import DenyAssignmentsOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import DenyAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'deny_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def eligible_child_resources(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`EligibleChildResourcesOperations` - * 2020-10-01-preview: :class:`EligibleChildResourcesOperations` - """ - api_version = self._get_api_version('eligible_child_resources') - if api_version == '2020-10-01': - from .v2020_10_01.operations import EligibleChildResourcesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import EligibleChildResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def global_administrator(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`GlobalAdministratorOperations` - """ - api_version = self._get_api_version('global_administrator') - if api_version == '2015-07-01': - from .v2015_07_01.operations import GlobalAdministratorOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'global_administrator'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`Operations` - * 2021-01-01-preview: :class:`Operations` - * 2021-03-01-preview: :class:`Operations` - * 2021-07-01-preview: :class:`Operations` - * 2021-12-01-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2018-05-01-preview': - from .v2018_05_01_preview.operations import Operations as OperationClass - elif api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import Operations as OperationClass - elif api_version == '2021-03-01-preview': - from .v2021_03_01_preview.operations import Operations as OperationClass - elif api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import Operations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def permissions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`PermissionsOperations` - * 2018-01-01-preview: :class:`PermissionsOperations` - * 2022-04-01: :class:`PermissionsOperations` - * 2022-05-01-preview: :class:`PermissionsOperations` - """ - api_version = self._get_api_version('permissions') - if api_version == '2015-07-01': - from .v2015_07_01.operations import PermissionsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from .v2018_01_01_preview.operations import PermissionsOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import PermissionsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from .v2022_05_01_preview.operations import PermissionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'permissions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def provider_operations_metadata(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`ProviderOperationsMetadataOperations` - * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations` - * 2022-04-01: :class:`ProviderOperationsMetadataOperations` - """ - api_version = self._get_api_version('provider_operations_metadata') - if api_version == '2015-07-01': - from .v2015_07_01.operations import ProviderOperationsMetadataOperations as OperationClass - elif api_version == '2018-01-01-preview': - from .v2018_01_01_preview.operations import ProviderOperationsMetadataOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import ProviderOperationsMetadataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'provider_operations_metadata'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalOperations` - """ - api_version = self._get_api_version('role_assignment_approval') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import RoleAssignmentApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval_step(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepOperations` - """ - api_version = self._get_api_version('role_assignment_approval_step') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import RoleAssignmentApprovalStepOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval_step'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval_steps(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepsOperations` - """ - api_version = self._get_api_version('role_assignment_approval_steps') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import RoleAssignmentApprovalStepsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval_steps'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_metrics(self): - """Instance depends on the API version: - - * 2019-08-01-preview: :class:`RoleAssignmentMetricsOperations` - """ - api_version = self._get_api_version('role_assignment_metrics') - if api_version == '2019-08-01-preview': - from .v2019_08_01_preview.operations import RoleAssignmentMetricsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_metrics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedule_instances(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations` - * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations` - """ - api_version = self._get_api_version('role_assignment_schedule_instances') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleAssignmentScheduleInstancesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleAssignmentScheduleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedule_requests(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` - * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` - * 2022-04-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` - """ - api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - elif api_version == '2022-04-01-preview': - from .v2022_04_01_preview.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedules(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentSchedulesOperations` - * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations` - """ - api_version = self._get_api_version('role_assignment_schedules') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleAssignmentSchedulesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleAssignmentSchedulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignments(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`RoleAssignmentsOperations` - * 2018-01-01-preview: :class:`RoleAssignmentsOperations` - * 2018-09-01-preview: :class:`RoleAssignmentsOperations` - * 2020-04-01-preview: :class:`RoleAssignmentsOperations` - * 2020-10-01-preview: :class:`RoleAssignmentsOperations` - * 2022-04-01: :class:`RoleAssignmentsOperations` - """ - api_version = self._get_api_version('role_assignments') - if api_version == '2015-07-01': - from .v2015_07_01.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from .v2018_01_01_preview.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2018-09-01-preview': - from .v2018_09_01_preview.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2020-04-01-preview': - from .v2020_04_01_preview.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import RoleAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_definitions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`RoleDefinitionsOperations` - * 2018-01-01-preview: :class:`RoleDefinitionsOperations` - * 2022-04-01: :class:`RoleDefinitionsOperations` - * 2022-05-01-preview: :class:`RoleDefinitionsOperations` - """ - api_version = self._get_api_version('role_definitions') - if api_version == '2015-07-01': - from .v2015_07_01.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from .v2018_01_01_preview.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2022-04-01': - from .v2022_04_01.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from .v2022_05_01_preview.operations import RoleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedule_instances(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations` - * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations` - """ - api_version = self._get_api_version('role_eligibility_schedule_instances') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleEligibilityScheduleInstancesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleEligibilityScheduleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedule_requests(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` - * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` - * 2022-04-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` - """ - api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - elif api_version == '2022-04-01-preview': - from .v2022_04_01_preview.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedules(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilitySchedulesOperations` - * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations` - """ - api_version = self._get_api_version('role_eligibility_schedules') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleEligibilitySchedulesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleEligibilitySchedulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_management_policies(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleManagementPoliciesOperations` - * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations` - """ - api_version = self._get_api_version('role_management_policies') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleManagementPoliciesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleManagementPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_management_policy_assignments(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations` - * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations` - """ - api_version = self._get_api_version('role_management_policy_assignments') - if api_version == '2020-10-01': - from .v2020_10_01.operations import RoleManagementPolicyAssignmentsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from .v2020_10_01_preview.operations import RoleManagementPolicyAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_default_settings(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewDefaultSettingsOperations` - """ - api_version = self._get_api_version('scope_access_review_default_settings') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewDefaultSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_default_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewHistoryDefinitionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstanceOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition_instance') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewHistoryDefinitionInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstancesOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition_instances') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewHistoryDefinitionInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionsOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definitions') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewHistoryDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceOperations` - """ - api_version = self._get_api_version('scope_access_review_instance') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('scope_access_review_instance_contacted_reviewers') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance_decisions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceDecisionsOperations` - """ - api_version = self._get_api_version('scope_access_review_instance_decisions') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewInstanceDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstancesOperations` - """ - api_version = self._get_api_version('scope_access_review_instances') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_schedule_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewScheduleDefinitionsOperations` - """ - api_version = self._get_api_version('scope_access_review_schedule_definitions') - if api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import ScopeAccessReviewScheduleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_schedule_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_role_assignment_approval(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalOperations` - """ - api_version = self._get_api_version('scope_role_assignment_approval') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import ScopeRoleAssignmentApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.classic_administrators = ClassicAdministratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.global_administrator = GlobalAdministratorOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deny_assignments = DenyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.provider_operations_metadata = ProviderOperationsMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignments = RoleAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instances = AccessReviewInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance = AccessReviewInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_schedule_definitions_assigned_for_my_approval = ( + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_level_access_review_instance_contacted_reviewers = ( + TenantLevelAccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.eligible_child_resources = EligibleChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_management_policies = RoleManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_configurations = AlertConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_definitions = AlertDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_incidents = AlertIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_operation = AlertOperationOperations(self._client, self._config, self._serialize, self._deserialize) - @property - def scope_role_assignment_approval_step(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepOperations` - """ - api_version = self._get_api_version('scope_role_assignment_approval_step') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import ScopeRoleAssignmentApprovalStepOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_step'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def scope_role_assignment_approval_steps(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepsOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse """ - api_version = self._get_api_version('scope_role_assignment_approval_steps') - if api_version == '2021-01-01-preview': - from .v2021_01_01_preview.operations import ScopeRoleAssignmentApprovalStepsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def tenant_level_access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` - * 2021-12-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') - if api_version == '2021-07-01-preview': - from .v2021_07_01_preview.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py index f52b9ee54234..8910ac6b06ab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py @@ -1,26 +1,23 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): + +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,36 +29,30 @@ class AuthorizationManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_patch.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/__init__.py similarity index 93% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/__init__.py index 77f53a3589c6..0af9b28f6607 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/__init__.py @@ -1,9 +1,6 @@ -# coding=utf-8 # -------------------------------------------------------------------------- # 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. # -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/serialization.py similarity index 79% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/serialization.py index e3cc6ce6ed6f..f5187701d7be 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_serialization.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -48,11 +30,8 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, - Mapping, ) try: @@ -62,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +70,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +93,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -124,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +124,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -153,6 +136,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +158,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -184,80 +165,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Dict[str, Any] = {} - for k in kwargs: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +244,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +280,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +293,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,14 +304,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[ - [str, Dict[str, Any], Any], Any - ] = attribute_transformer, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -387,12 +340,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -402,30 +358,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -433,9 +390,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -447,7 +406,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -455,21 +414,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -508,11 +471,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -547,7 +512,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -563,17 +528,20 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -599,12 +567,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -640,7 +610,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -651,7 +622,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -664,23 +635,24 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -709,20 +681,22 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -731,30 +705,30 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -764,19 +738,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -785,32 +760,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -825,12 +799,11 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -846,23 +819,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -876,8 +852,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -887,13 +862,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -905,9 +880,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -943,16 +923,17 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -967,7 +948,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -975,6 +956,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -985,7 +967,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -999,7 +981,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1030,56 +1012,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1087,11 +1074,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1101,30 +1089,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1137,12 +1127,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1162,19 +1153,20 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1182,11 +1174,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1201,14 +1193,15 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1222,7 +1215,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,17 +1222,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1277,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1329,22 +1333,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1352,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1361,9 +1364,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1383,7 +1386,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1399,27 +1402,29 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1436,15 +1441,15 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1473,10 +1478,9 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1503,18 +1507,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1529,10 +1535,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1550,10 +1558,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1570,31 +1580,42 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1603,15 +1624,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1625,7 +1647,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1644,15 +1670,15 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1669,6 +1695,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1679,20 +1706,21 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1718,11 +1746,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1730,8 +1757,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1741,24 +1769,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1766,6 +1793,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1779,8 +1807,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1792,6 +1819,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1800,12 +1828,11 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1821,8 +1848,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1833,8 +1861,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1848,24 +1877,26 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1876,8 +1907,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1885,32 +1917,33 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1923,31 +1956,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1974,9 +2008,8 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1984,15 +2017,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_version.py index 5a310ec590fb..3f948557870d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "5.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/__init__.py index ffc49d028e42..ec3fdce8fdae 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/__init__.py @@ -5,6 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._authorization_management_client import AuthorizationManagementClient -__all__ = ['AuthorizationManagementClient'] +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._authorization_management_client import AuthorizationManagementClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AuthorizationManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py index 030b0658dbf1..bfca8232b064 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py @@ -1,1125 +1,439 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .._serialization import Deserializer, Serializer +from .. import models as _models +from .._utils.serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration +from .operations import ( + AccessReviewDefaultSettingsOperations, + AccessReviewHistoryDefinitionInstanceOperations, + AccessReviewHistoryDefinitionInstancesOperations, + AccessReviewHistoryDefinitionOperations, + AccessReviewHistoryDefinitionsOperations, + AccessReviewInstanceContactedReviewersOperations, + AccessReviewInstanceDecisionsOperations, + AccessReviewInstanceMyDecisionsOperations, + AccessReviewInstanceOperations, + AccessReviewInstancesAssignedForMyApprovalOperations, + AccessReviewInstancesOperations, + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, + AccessReviewScheduleDefinitionsOperations, + AlertConfigurationsOperations, + AlertDefinitionsOperations, + AlertIncidentsOperations, + AlertOperationOperations, + AlertsOperations, + ClassicAdministratorsOperations, + DenyAssignmentsOperations, + EligibleChildResourcesOperations, + GlobalAdministratorOperations, + Operations, + PermissionsOperations, + ProviderOperationsMetadataOperations, + RoleAssignmentScheduleInstancesOperations, + RoleAssignmentScheduleRequestsOperations, + RoleAssignmentSchedulesOperations, + RoleAssignmentsOperations, + RoleDefinitionsOperations, + RoleEligibilityScheduleInstancesOperations, + RoleEligibilityScheduleRequestsOperations, + RoleEligibilitySchedulesOperations, + RoleManagementPoliciesOperations, + RoleManagementPolicyAssignmentsOperations, + ScopeAccessReviewDefaultSettingsOperations, + ScopeAccessReviewHistoryDefinitionInstanceOperations, + ScopeAccessReviewHistoryDefinitionInstancesOperations, + ScopeAccessReviewHistoryDefinitionOperations, + ScopeAccessReviewHistoryDefinitionsOperations, + ScopeAccessReviewInstanceContactedReviewersOperations, + ScopeAccessReviewInstanceDecisionsOperations, + ScopeAccessReviewInstanceOperations, + ScopeAccessReviewInstancesOperations, + ScopeAccessReviewScheduleDefinitionsOperations, + TenantLevelAccessReviewInstanceContactedReviewersOperations, +) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass - -class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. - - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. +class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. + + :ivar classic_administrators: ClassicAdministratorsOperations operations + :vartype classic_administrators: + azure.mgmt.authorization.aio.operations.ClassicAdministratorsOperations + :ivar global_administrator: GlobalAdministratorOperations operations + :vartype global_administrator: + azure.mgmt.authorization.aio.operations.GlobalAdministratorOperations + :ivar deny_assignments: DenyAssignmentsOperations operations + :vartype deny_assignments: azure.mgmt.authorization.aio.operations.DenyAssignmentsOperations + :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations + :vartype provider_operations_metadata: + azure.mgmt.authorization.aio.operations.ProviderOperationsMetadataOperations + :ivar role_assignments: RoleAssignmentsOperations operations + :vartype role_assignments: azure.mgmt.authorization.aio.operations.RoleAssignmentsOperations + :ivar permissions: PermissionsOperations operations + :vartype permissions: azure.mgmt.authorization.aio.operations.PermissionsOperations + :ivar role_definitions: RoleDefinitionsOperations operations + :vartype role_definitions: azure.mgmt.authorization.aio.operations.RoleDefinitionsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.authorization.aio.operations.Operations + :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations + :vartype access_review_history_definitions: + azure.mgmt.authorization.aio.operations.AccessReviewHistoryDefinitionsOperations + :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations + :vartype access_review_history_definition: + azure.mgmt.authorization.aio.operations.AccessReviewHistoryDefinitionOperations + :ivar access_review_history_definition_instance: + AccessReviewHistoryDefinitionInstanceOperations operations + :vartype access_review_history_definition_instance: + azure.mgmt.authorization.aio.operations.AccessReviewHistoryDefinitionInstanceOperations + :ivar access_review_history_definition_instances: + AccessReviewHistoryDefinitionInstancesOperations operations + :vartype access_review_history_definition_instances: + azure.mgmt.authorization.aio.operations.AccessReviewHistoryDefinitionInstancesOperations + :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.aio.operations.AccessReviewScheduleDefinitionsOperations + :ivar access_review_instances: AccessReviewInstancesOperations operations + :vartype access_review_instances: + azure.mgmt.authorization.aio.operations.AccessReviewInstancesOperations + :ivar access_review_instance: AccessReviewInstanceOperations operations + :vartype access_review_instance: + azure.mgmt.authorization.aio.operations.AccessReviewInstanceOperations + :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.aio.operations.AccessReviewInstanceDecisionsOperations + :ivar access_review_instance_contacted_reviewers: + AccessReviewInstanceContactedReviewersOperations operations + :vartype access_review_instance_contacted_reviewers: + azure.mgmt.authorization.aio.operations.AccessReviewInstanceContactedReviewersOperations + :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations + :vartype access_review_default_settings: + azure.mgmt.authorization.aio.operations.AccessReviewDefaultSettingsOperations + :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations + operations + :vartype scope_access_review_history_definitions: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations + :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations + operations + :vartype scope_access_review_history_definition: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewHistoryDefinitionOperations + :ivar scope_access_review_history_definition_instance: + ScopeAccessReviewHistoryDefinitionInstanceOperations operations + :vartype scope_access_review_history_definition_instance: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations + :ivar scope_access_review_history_definition_instances: + ScopeAccessReviewHistoryDefinitionInstancesOperations operations + :vartype scope_access_review_history_definition_instances: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations + :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations + operations + :vartype scope_access_review_schedule_definitions: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations + :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations + :vartype scope_access_review_instances: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewInstancesOperations + :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations + :vartype scope_access_review_instance: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewInstanceOperations + :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations + operations + :vartype scope_access_review_instance_decisions: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewInstanceDecisionsOperations + :ivar scope_access_review_instance_contacted_reviewers: + ScopeAccessReviewInstanceContactedReviewersOperations operations + :vartype scope_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations + :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations + operations + :vartype scope_access_review_default_settings: + azure.mgmt.authorization.aio.operations.ScopeAccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.aio.operations.AccessReviewInstanceMyDecisionsOperations + :ivar tenant_level_access_review_instance_contacted_reviewers: + TenantLevelAccessReviewInstanceContactedReviewersOperations operations + :vartype tenant_level_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations + :ivar eligible_child_resources: EligibleChildResourcesOperations operations + :vartype eligible_child_resources: + azure.mgmt.authorization.aio.operations.EligibleChildResourcesOperations + :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations + :vartype role_assignment_schedules: + azure.mgmt.authorization.aio.operations.RoleAssignmentSchedulesOperations + :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.aio.operations.RoleAssignmentScheduleInstancesOperations + :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.aio.operations.RoleAssignmentScheduleRequestsOperations + :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.aio.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.aio.operations.RoleEligibilityScheduleInstancesOperations + :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.aio.operations.RoleEligibilityScheduleRequestsOperations + :ivar role_management_policies: RoleManagementPoliciesOperations operations + :vartype role_management_policies: + azure.mgmt.authorization.aio.operations.RoleManagementPoliciesOperations + :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.aio.operations.RoleManagementPolicyAssignmentsOperations + :ivar alerts: AlertsOperations operations + :vartype alerts: azure.mgmt.authorization.aio.operations.AlertsOperations + :ivar alert_configurations: AlertConfigurationsOperations operations + :vartype alert_configurations: + azure.mgmt.authorization.aio.operations.AlertConfigurationsOperations + :ivar alert_definitions: AlertDefinitionsOperations operations + :vartype alert_definitions: azure.mgmt.authorization.aio.operations.AlertDefinitionsOperations + :ivar alert_incidents: AlertIncidentsOperations operations + :vartype alert_incidents: azure.mgmt.authorization.aio.operations.AlertIncidentsOperations + :ivar alert_operation: AlertOperationOperations operations + :vartype alert_operation: azure.mgmt.authorization.aio.operations.AlertOperationOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-04-01' - _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - 'access_review_default_settings': '2021-12-01-preview', - 'access_review_history_definition': '2021-12-01-preview', - 'access_review_history_definition_instance': '2021-12-01-preview', - 'access_review_history_definition_instances': '2021-12-01-preview', - 'access_review_history_definitions': '2021-12-01-preview', - 'access_review_instance': '2021-12-01-preview', - 'access_review_instance_contacted_reviewers': '2021-12-01-preview', - 'access_review_instance_decisions': '2021-12-01-preview', - 'access_review_instance_my_decisions': '2021-12-01-preview', - 'access_review_instances': '2021-12-01-preview', - 'access_review_instances_assigned_for_my_approval': '2021-12-01-preview', - 'access_review_schedule_definitions': '2021-12-01-preview', - 'access_review_schedule_definitions_assigned_for_my_approval': '2021-12-01-preview', - 'classic_administrators': '2015-07-01', - 'eligible_child_resources': '2020-10-01', - 'global_administrator': '2015-07-01', - 'operations': '2021-12-01-preview', - 'role_assignment_approval': '2021-01-01-preview', - 'role_assignment_approval_step': '2021-01-01-preview', - 'role_assignment_approval_steps': '2021-01-01-preview', - 'role_assignment_metrics': '2019-08-01-preview', - 'role_assignment_schedule_instances': '2020-10-01', - 'role_assignment_schedule_requests': '2020-10-01', - 'role_assignment_schedules': '2020-10-01', - 'role_eligibility_schedule_instances': '2020-10-01', - 'role_eligibility_schedule_requests': '2020-10-01', - 'role_eligibility_schedules': '2020-10-01', - 'role_management_policies': '2020-10-01', - 'role_management_policy_assignments': '2020-10-01', - 'scope_access_review_default_settings': '2021-12-01-preview', - 'scope_access_review_history_definition': '2021-12-01-preview', - 'scope_access_review_history_definition_instance': '2021-12-01-preview', - 'scope_access_review_history_definition_instances': '2021-12-01-preview', - 'scope_access_review_history_definitions': '2021-12-01-preview', - 'scope_access_review_instance': '2021-12-01-preview', - 'scope_access_review_instance_contacted_reviewers': '2021-12-01-preview', - 'scope_access_review_instance_decisions': '2021-12-01-preview', - 'scope_access_review_instances': '2021-12-01-preview', - 'scope_access_review_schedule_definitions': '2021-12-01-preview', - 'scope_role_assignment_approval': '2021-01-01-preview', - 'scope_role_assignment_approval_step': '2021-01-01-preview', - 'scope_role_assignment_approval_steps': '2021-01-01-preview', - 'tenant_level_access_review_instance_contacted_reviewers': '2021-12-01-preview', - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - api_version: Optional[str] = None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - super(AuthorizationManagementClient, self).__init__( - api_version=api_version, - profile=profile + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = AuthorizationManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2015-06-01: :mod:`v2015_06_01.models` - * 2015-07-01: :mod:`v2015_07_01.models` - * 2018-01-01-preview: :mod:`v2018_01_01_preview.models` - * 2018-05-01-preview: :mod:`v2018_05_01_preview.models` - * 2018-07-01-preview: :mod:`v2018_07_01_preview.models` - * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` - * 2019-08-01-preview: :mod:`v2019_08_01_preview.models` - * 2020-04-01-preview: :mod:`v2020_04_01_preview.models` - * 2020-10-01: :mod:`v2020_10_01.models` - * 2020-10-01-preview: :mod:`v2020_10_01_preview.models` - * 2021-01-01-preview: :mod:`v2021_01_01_preview.models` - * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` - * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` - * 2021-12-01-preview: :mod:`v2021_12_01_preview.models` - * 2022-04-01: :mod:`v2022_04_01.models` - * 2022-04-01-preview: :mod:`v2022_04_01_preview.models` - * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` - * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` - """ - if api_version == '2015-06-01': - from ..v2015_06_01 import models - return models - elif api_version == '2015-07-01': - from ..v2015_07_01 import models - return models - elif api_version == '2018-01-01-preview': - from ..v2018_01_01_preview import models - return models - elif api_version == '2018-05-01-preview': - from ..v2018_05_01_preview import models - return models - elif api_version == '2018-07-01-preview': - from ..v2018_07_01_preview import models - return models - elif api_version == '2018-09-01-preview': - from ..v2018_09_01_preview import models - return models - elif api_version == '2019-08-01-preview': - from ..v2019_08_01_preview import models - return models - elif api_version == '2020-04-01-preview': - from ..v2020_04_01_preview import models - return models - elif api_version == '2020-10-01': - from ..v2020_10_01 import models - return models - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview import models - return models - elif api_version == '2021-01-01-preview': - from ..v2021_01_01_preview import models - return models - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview import models - return models - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview import models - return models - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview import models - return models - elif api_version == '2022-04-01': - from ..v2022_04_01 import models - return models - elif api_version == '2022-04-01-preview': - from ..v2022_04_01_preview import models - return models - elif api_version == '2022-05-01-preview': - from ..v2022_05_01_preview import models - return models - elif api_version == '2022-08-01-preview': - from ..v2022_08_01_preview import models - return models - raise ValueError("API version {} is not available".format(api_version)) - - @property - def access_review_default_settings(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations` - * 2021-12-01-preview: :class:`AccessReviewDefaultSettingsOperations` - """ - api_version = self._get_api_version('access_review_default_settings') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionOperations` - """ - api_version = self._get_api_version('access_review_history_definition') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstanceOperations` - """ - api_version = self._get_api_version('access_review_history_definition_instance') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definition_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstancesOperations` - """ - api_version = self._get_api_version('access_review_history_definition_instances') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definition_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_history_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionsOperations` - """ - api_version = self._get_api_version('access_review_history_definitions') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_history_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceOperations` - """ - api_version = self._get_api_version('access_review_instance') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - - * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('access_review_instance_contacted_reviewers') - if api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_decisions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceDecisionsOperations` - """ - api_version = self._get_api_version('access_review_instance_decisions') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instance_my_decisions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - * 2021-12-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` - """ - api_version = self._get_api_version('access_review_instance_my_decisions') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instances(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-07-01-preview: :class:`AccessReviewInstancesOperations` - * 2021-12-01-preview: :class:`AccessReviewInstancesOperations` - """ - api_version = self._get_api_version('access_review_instances') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_instances_assigned_for_my_approval(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - * 2021-12-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` - """ - api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_schedule_definitions(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` - """ - api_version = self._get_api_version('access_review_schedule_definitions') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def access_review_schedule_definitions_assigned_for_my_approval(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` - """ - api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_configurations(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertConfigurationsOperations` - """ - api_version = self._get_api_version('alert_configurations') - if api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import AlertConfigurationsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_configurations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_definitions(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertDefinitionsOperations` - """ - api_version = self._get_api_version('alert_definitions') - if api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import AlertDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_incidents(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertIncidentsOperations` - """ - api_version = self._get_api_version('alert_incidents') - if api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import AlertIncidentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_incidents'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alert_operation(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertOperationOperations` - """ - api_version = self._get_api_version('alert_operation') - if api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import AlertOperationOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alert_operation'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def alerts(self): - """Instance depends on the API version: - - * 2022-08-01-preview: :class:`AlertsOperations` - """ - api_version = self._get_api_version('alerts') - if api_version == '2022-08-01-preview': - from ..v2022_08_01_preview.aio.operations import AlertsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def classic_administrators(self): - """Instance depends on the API version: - - * 2015-06-01: :class:`ClassicAdministratorsOperations` - * 2015-07-01: :class:`ClassicAdministratorsOperations` - """ - api_version = self._get_api_version('classic_administrators') - if api_version == '2015-06-01': - from ..v2015_06_01.aio.operations import ClassicAdministratorsOperations as OperationClass - elif api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import ClassicAdministratorsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'classic_administrators'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def deny_assignments(self): - """Instance depends on the API version: - - * 2018-07-01-preview: :class:`DenyAssignmentsOperations` - * 2022-04-01: :class:`DenyAssignmentsOperations` - """ - api_version = self._get_api_version('deny_assignments') - if api_version == '2018-07-01-preview': - from ..v2018_07_01_preview.aio.operations import DenyAssignmentsOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import DenyAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'deny_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def eligible_child_resources(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`EligibleChildResourcesOperations` - * 2020-10-01-preview: :class:`EligibleChildResourcesOperations` - """ - api_version = self._get_api_version('eligible_child_resources') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import EligibleChildResourcesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import EligibleChildResourcesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def global_administrator(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`GlobalAdministratorOperations` - """ - api_version = self._get_api_version('global_administrator') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import GlobalAdministratorOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'global_administrator'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2018-05-01-preview: :class:`Operations` - * 2021-01-01-preview: :class:`Operations` - * 2021-03-01-preview: :class:`Operations` - * 2021-07-01-preview: :class:`Operations` - * 2021-12-01-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2018-05-01-preview': - from ..v2018_05_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-03-01-preview': - from ..v2021_03_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import Operations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def permissions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`PermissionsOperations` - * 2018-01-01-preview: :class:`PermissionsOperations` - * 2022-04-01: :class:`PermissionsOperations` - * 2022-05-01-preview: :class:`PermissionsOperations` - """ - api_version = self._get_api_version('permissions') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import PermissionsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from ..v2018_01_01_preview.aio.operations import PermissionsOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import PermissionsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from ..v2022_05_01_preview.aio.operations import PermissionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'permissions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def provider_operations_metadata(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`ProviderOperationsMetadataOperations` - * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations` - * 2022-04-01: :class:`ProviderOperationsMetadataOperations` - """ - api_version = self._get_api_version('provider_operations_metadata') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass - elif api_version == '2018-01-01-preview': - from ..v2018_01_01_preview.aio.operations import ProviderOperationsMetadataOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'provider_operations_metadata'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalOperations` - """ - api_version = self._get_api_version('role_assignment_approval') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval_step(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepOperations` - """ - api_version = self._get_api_version('role_assignment_approval_step') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval_step'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_approval_steps(self): - """Instance depends on the API version: - - * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepsOperations` - """ - api_version = self._get_api_version('role_assignment_approval_steps') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_approval_steps'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_metrics(self): - """Instance depends on the API version: - - * 2019-08-01-preview: :class:`RoleAssignmentMetricsOperations` - """ - api_version = self._get_api_version('role_assignment_metrics') - if api_version == '2019-08-01-preview': - from ..v2019_08_01_preview.aio.operations import RoleAssignmentMetricsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_metrics'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedule_instances(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations` - * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations` - """ - api_version = self._get_api_version('role_assignment_schedule_instances') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedule_requests(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` - * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` - * 2022-04-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` - """ - api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - elif api_version == '2022-04-01-preview': - from ..v2022_04_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignment_schedules(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleAssignmentSchedulesOperations` - * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations` - """ - api_version = self._get_api_version('role_assignment_schedules') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleAssignmentSchedulesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleAssignmentSchedulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_assignments(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`RoleAssignmentsOperations` - * 2018-01-01-preview: :class:`RoleAssignmentsOperations` - * 2018-09-01-preview: :class:`RoleAssignmentsOperations` - * 2020-04-01-preview: :class:`RoleAssignmentsOperations` - * 2020-10-01-preview: :class:`RoleAssignmentsOperations` - * 2022-04-01: :class:`RoleAssignmentsOperations` - """ - api_version = self._get_api_version('role_assignments') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from ..v2018_01_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2018-09-01-preview': - from ..v2018_09_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2020-04-01-preview': - from ..v2020_04_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import RoleAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_definitions(self): - """Instance depends on the API version: - - * 2015-07-01: :class:`RoleDefinitionsOperations` - * 2018-01-01-preview: :class:`RoleDefinitionsOperations` - * 2022-04-01: :class:`RoleDefinitionsOperations` - * 2022-05-01-preview: :class:`RoleDefinitionsOperations` - """ - api_version = self._get_api_version('role_definitions') - if api_version == '2015-07-01': - from ..v2015_07_01.aio.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2018-01-01-preview': - from ..v2018_01_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2022-04-01': - from ..v2022_04_01.aio.operations import RoleDefinitionsOperations as OperationClass - elif api_version == '2022-05-01-preview': - from ..v2022_05_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedule_instances(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations` - * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations` - """ - api_version = self._get_api_version('role_eligibility_schedule_instances') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedule_requests(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` - * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` - * 2022-04-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` - """ - api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - elif api_version == '2022-04-01-preview': - from ..v2022_04_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_eligibility_schedules(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleEligibilitySchedulesOperations` - * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations` - """ - api_version = self._get_api_version('role_eligibility_schedules') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleEligibilitySchedulesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleEligibilitySchedulesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_management_policies(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleManagementPoliciesOperations` - * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations` - """ - api_version = self._get_api_version('role_management_policies') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleManagementPoliciesOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleManagementPoliciesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def role_management_policy_assignments(self): - """Instance depends on the API version: - - * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations` - * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations` - """ - api_version = self._get_api_version('role_management_policy_assignments') - if api_version == '2020-10-01': - from ..v2020_10_01.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass - elif api_version == '2020-10-01-preview': - from ..v2020_10_01_preview.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_default_settings(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewDefaultSettingsOperations` - """ - api_version = self._get_api_version('scope_access_review_default_settings') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewDefaultSettingsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_default_settings'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstanceOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition_instance') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definition_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstancesOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definition_instances') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_history_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionsOperations` - """ - api_version = self._get_api_version('scope_access_review_history_definitions') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_history_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceOperations` - """ - api_version = self._get_api_version('scope_access_review_instance') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('scope_access_review_instance_contacted_reviewers') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instance_decisions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceDecisionsOperations` - """ - api_version = self._get_api_version('scope_access_review_instance_decisions') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceDecisionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instance_decisions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_instances(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewInstancesOperations` - """ - api_version = self._get_api_version('scope_access_review_instances') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstancesOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_instances'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_access_review_schedule_definitions(self): - """Instance depends on the API version: - - * 2021-12-01-preview: :class:`ScopeAccessReviewScheduleDefinitionsOperations` - """ - api_version = self._get_api_version('scope_access_review_schedule_definitions') - if api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewScheduleDefinitionsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_access_review_schedule_definitions'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def scope_role_assignment_approval(self): - """Instance depends on the API version: + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalOperations` - """ - api_version = self._get_api_version('scope_role_assignment_approval') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.classic_administrators = ClassicAdministratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.global_administrator = GlobalAdministratorOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deny_assignments = DenyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.provider_operations_metadata = ProviderOperationsMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignments = RoleAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instances = AccessReviewInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance = AccessReviewInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_schedule_definitions_assigned_for_my_approval = ( + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_level_access_review_instance_contacted_reviewers = ( + TenantLevelAccessReviewInstanceContactedReviewersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.eligible_child_resources = EligibleChildResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_management_policies = RoleManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_configurations = AlertConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_definitions = AlertDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_incidents = AlertIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_operation = AlertOperationOperations(self._client, self._config, self._serialize, self._deserialize) - @property - def scope_role_assignment_approval_step(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepOperations` - """ - api_version = self._get_api_version('scope_role_assignment_approval_step') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_step'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def scope_role_assignment_approval_steps(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepsOperations` + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse """ - api_version = self._get_api_version('scope_role_assignment_approval_steps') - if api_version == '2021-01-01-preview': - from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepsOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) - - @property - def tenant_level_access_review_instance_contacted_reviewers(self): - """Instance depends on the API version: - * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` - * 2021-12-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` - """ - api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') - if api_version == '2021-07-01-preview': - from ..v2021_07_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) - self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py index a9ce559ac2cf..22cd5c6a1cf9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py @@ -1,26 +1,23 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): + +class AuthorizationManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,36 +29,30 @@ class AuthorizationManagementClientConfiguration(Configuration): :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_patch.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_patch.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_patch.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/__init__.py new file mode 100644 index 000000000000..6ea9c98641fb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/__init__.py @@ -0,0 +1,116 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._classic_administrators_operations import ClassicAdministratorsOperations # type: ignore +from ._global_administrator_operations import GlobalAdministratorOperations # type: ignore +from ._deny_assignments_operations import DenyAssignmentsOperations # type: ignore +from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations # type: ignore +from ._role_assignments_operations import RoleAssignmentsOperations # type: ignore +from ._permissions_operations import PermissionsOperations # type: ignore +from ._role_definitions_operations import RoleDefinitionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations # type: ignore +from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations # type: ignore +from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations # type: ignore +from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations # type: ignore +from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations # type: ignore +from ._access_review_instances_operations import AccessReviewInstancesOperations # type: ignore +from ._access_review_instance_operations import AccessReviewInstanceOperations # type: ignore +from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations # type: ignore +from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations # type: ignore +from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations # type: ignore +from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations # type: ignore +from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations # type: ignore +from ._scope_access_review_history_definition_instance_operations import ScopeAccessReviewHistoryDefinitionInstanceOperations # type: ignore +from ._scope_access_review_history_definition_instances_operations import ScopeAccessReviewHistoryDefinitionInstancesOperations # type: ignore +from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations # type: ignore +from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations # type: ignore +from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations # type: ignore +from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations # type: ignore +from ._scope_access_review_instance_contacted_reviewers_operations import ScopeAccessReviewInstanceContactedReviewersOperations # type: ignore +from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations # type: ignore +from ._access_review_schedule_definitions_assigned_for_my_approval_operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations # type: ignore +from ._access_review_instances_assigned_for_my_approval_operations import AccessReviewInstancesAssignedForMyApprovalOperations # type: ignore +from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations # type: ignore +from ._tenant_level_access_review_instance_contacted_reviewers_operations import TenantLevelAccessReviewInstanceContactedReviewersOperations # type: ignore +from ._eligible_child_resources_operations import EligibleChildResourcesOperations # type: ignore +from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations # type: ignore +from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations # type: ignore +from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations # type: ignore +from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations # type: ignore +from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations # type: ignore +from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations # type: ignore +from ._role_management_policies_operations import RoleManagementPoliciesOperations # type: ignore +from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations # type: ignore +from ._alerts_operations import AlertsOperations # type: ignore +from ._alert_configurations_operations import AlertConfigurationsOperations # type: ignore +from ._alert_definitions_operations import AlertDefinitionsOperations # type: ignore +from ._alert_incidents_operations import AlertIncidentsOperations # type: ignore +from ._alert_operation_operations import AlertOperationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClassicAdministratorsOperations", + "GlobalAdministratorOperations", + "DenyAssignmentsOperations", + "ProviderOperationsMetadataOperations", + "RoleAssignmentsOperations", + "PermissionsOperations", + "RoleDefinitionsOperations", + "Operations", + "AccessReviewHistoryDefinitionsOperations", + "AccessReviewHistoryDefinitionOperations", + "AccessReviewHistoryDefinitionInstanceOperations", + "AccessReviewHistoryDefinitionInstancesOperations", + "AccessReviewScheduleDefinitionsOperations", + "AccessReviewInstancesOperations", + "AccessReviewInstanceOperations", + "AccessReviewInstanceDecisionsOperations", + "AccessReviewInstanceContactedReviewersOperations", + "AccessReviewDefaultSettingsOperations", + "ScopeAccessReviewHistoryDefinitionsOperations", + "ScopeAccessReviewHistoryDefinitionOperations", + "ScopeAccessReviewHistoryDefinitionInstanceOperations", + "ScopeAccessReviewHistoryDefinitionInstancesOperations", + "ScopeAccessReviewScheduleDefinitionsOperations", + "ScopeAccessReviewInstancesOperations", + "ScopeAccessReviewInstanceOperations", + "ScopeAccessReviewInstanceDecisionsOperations", + "ScopeAccessReviewInstanceContactedReviewersOperations", + "ScopeAccessReviewDefaultSettingsOperations", + "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", + "AccessReviewInstancesAssignedForMyApprovalOperations", + "AccessReviewInstanceMyDecisionsOperations", + "TenantLevelAccessReviewInstanceContactedReviewersOperations", + "EligibleChildResourcesOperations", + "RoleAssignmentSchedulesOperations", + "RoleAssignmentScheduleInstancesOperations", + "RoleAssignmentScheduleRequestsOperations", + "RoleEligibilitySchedulesOperations", + "RoleEligibilityScheduleInstancesOperations", + "RoleEligibilityScheduleRequestsOperations", + "RoleManagementPoliciesOperations", + "RoleManagementPolicyAssignmentsOperations", + "AlertsOperations", + "AlertConfigurationsOperations", + "AlertDefinitionsOperations", + "AlertIncidentsOperations", + "AlertOperationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_default_settings_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_default_settings_operations.py index b45ea7aa5b68..a5ce04b28fad 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_default_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_default_settings_operations import build_get_request, build_put_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +39,7 @@ class AccessReviewDefaultSettingsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ @@ -46,22 +47,22 @@ class AccessReviewDefaultSettingsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -72,24 +73,20 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -99,16 +96,12 @@ async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload async def put( @@ -117,53 +110,45 @@ async def put( """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -174,9 +159,7 @@ async def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) @@ -188,22 +171,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,13 +194,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instance_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instance_operations.py index 19054fa67e9f..2d7b18faf884 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instance_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,27 +18,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_history_definition_instance_operations import build_generate_download_uri_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewHistoryDefinitionInstanceOperations: +class AccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ @@ -45,11 +46,12 @@ class AccessReviewHistoryDefinitionInstanceOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def generate_download_uri( @@ -63,12 +65,11 @@ async def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,26 +80,22 @@ async def generate_download_uri( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +105,9 @@ async def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_download_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instances_operations.py similarity index 60% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instances_operations.py index 2d55e63dfc3c..f478de75e997 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_history_definition_instances_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewHistoryDefinitionInstancesOperations: +class AccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ @@ -47,34 +47,32 @@ class AccessReviewHistoryDefinitionInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: + def list(self, history_definition_id: str, **kwargs: Any) -> AsyncItemPaged["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,34 +83,20 @@ def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_mod def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -122,11 +106,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,7 +122,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_operations.py index d666347c29aa..4ae7bb62fe83 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definition_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_history_definition_operations import build_create_request, build_delete_by_id_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +39,7 @@ class AccessReviewHistoryDefinitionOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ @@ -46,11 +47,12 @@ class AccessReviewHistoryDefinitionOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def create( @@ -66,33 +68,35 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( - self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + history_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -100,7 +104,7 @@ async def create( async def create( self, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -108,19 +112,14 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties or + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,9 +130,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) @@ -145,23 +142,21 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -171,31 +166,24 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, history_definition_id: str, **kwargs: Any - ) -> None: + async def delete_by_id(self, history_definition_id: str, **kwargs: Any) -> None: """Delete an access review history definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,25 +194,21 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,8 +219,4 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definitions_operations.py similarity index 63% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definitions_operations.py index c0104ae55246..2c778c8ec57b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_history_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +19,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_history_definitions_operations import build_get_by_id_request, build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ class AccessReviewHistoryDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ @@ -48,38 +48,36 @@ class AccessReviewHistoryDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewHistoryDefinition"]: + ) -> AsyncItemPaged["_models.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,34 +88,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -127,11 +111,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,22 +128,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions" - } - @distributed_trace_async async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,25 +149,21 @@ async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +173,9 @@ async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models. error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_contacted_reviewers_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_contacted_reviewers_operations.py index 47489dcd5700..7eaa6ee36c12 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ @@ -47,38 +47,36 @@ class AccessReviewInstanceContactedReviewersOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: + ) -> AsyncItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,35 +87,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -127,11 +111,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,7 +127,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_decisions_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_decisions_operations.py index 7b6e6c3cc8a2..57d18b71dff5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instance_decisions_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ class AccessReviewInstanceDecisionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ @@ -47,16 +47,17 @@ class AccessReviewInstanceDecisionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: + ) -> AsyncItemPaged["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -68,22 +69,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,36 +92,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -133,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,7 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_my_decisions_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_my_decisions_operations.py index dcc1e43bb936..da2e1ec50b4b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,32 +20,32 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ @@ -53,16 +53,17 @@ class AccessReviewInstanceMyDecisionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: + ) -> AsyncItemPaged["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -74,22 +75,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,35 +98,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -138,11 +122,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +139,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -171,12 +151,11 @@ async def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,26 +166,22 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +191,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload async def patch( @@ -247,14 +218,12 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @@ -264,7 +233,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,13 +247,12 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @@ -294,7 +262,7 @@ async def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -306,18 +274,13 @@ async def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewDecisionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewDecisionProperties or IO[bytes] :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,9 +291,7 @@ async def patch( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) @@ -342,7 +303,7 @@ async def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -350,16 +311,14 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +328,9 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_operations.py similarity index 65% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_operations.py index c6ba63176273..f3aa5f3938c8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instance_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,14 +18,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, @@ -32,6 +32,7 @@ build_send_reminders_request, build_stop_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +44,7 @@ class AccessReviewInstanceOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ @@ -51,28 +52,26 @@ class AccessReviewInstanceOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def stop(self, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,26 +82,22 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,28 +108,21 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def reset_decisions(self, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,26 +133,22 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,28 +159,21 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def apply_decisions(self, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,26 +184,22 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -237,28 +210,21 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def send_reminders(self, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -269,26 +235,22 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,28 +261,21 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def accept_recommendations(self, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,25 +286,21 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -360,8 +311,4 @@ async def accept_recommendations( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 2f93b7d715eb..f2f2c7cab282 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,31 +19,31 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instances_assigned_for_my_approval_operations import ( build_get_by_id_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ @@ -51,16 +51,17 @@ class AccessReviewInstancesAssignedForMyApprovalOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: + ) -> AsyncItemPaged["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -70,22 +71,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,34 +94,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -133,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +134,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -162,12 +142,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,25 +157,21 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,13 +181,9 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_operations.py index e7b6e5ab3458..92c7d7aff224 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,20 +20,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +45,7 @@ class AccessReviewInstancesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ @@ -53,16 +53,17 @@ class AccessReviewInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: + ) -> AsyncItemPaged["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -72,22 +73,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,35 +96,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -136,11 +120,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,10 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -165,12 +145,11 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,26 +160,22 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +185,12 @@ async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload async def create( @@ -238,14 +209,12 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -254,7 +223,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -266,13 +235,12 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -281,7 +249,7 @@ async def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -291,18 +259,13 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewInstanceProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties or IO[bytes] :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -313,9 +276,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) @@ -327,7 +288,7 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -335,16 +296,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,13 +313,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py similarity index 63% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 1d4319be31b7..b09e3c523993 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ @@ -47,16 +47,17 @@ class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: + ) -> AsyncItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom @@ -64,22 +65,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,33 +88,19 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -126,11 +110,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +126,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_operations.py index 0f992fe32c8f..b9732b98f5de 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -36,18 +35,19 @@ build_list_request, build_stop_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ @@ -55,16 +55,17 @@ class AccessReviewScheduleDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: + ) -> AsyncItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom @@ -72,22 +73,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,34 +96,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -135,11 +119,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,22 +136,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,25 +157,21 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,31 +181,24 @@ async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: + async def delete_by_id(self, schedule_definition_id: str, **kwargs: Any) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,25 +209,21 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,11 +234,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -290,33 +250,35 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -324,7 +286,7 @@ async def create_or_update_by_id( async def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -332,19 +294,14 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties or + IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,9 +312,7 @@ async def create_or_update_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) @@ -369,23 +324,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -395,31 +348,24 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: + async def stop(self, schedule_definition_id: str, **kwargs: Any) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -430,25 +376,21 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -459,8 +401,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_configurations_operations.py similarity index 65% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_configurations_operations.py index d9f81bb3f78b..c5fc50f9ba3d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_configurations_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,20 +21,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._alert_configurations_operations import ( build_get_request, build_list_for_scope_request, build_update_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +46,7 @@ class AlertConfigurationsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ @@ -53,11 +54,12 @@ class AlertConfigurationsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: @@ -73,12 +75,11 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration + :rtype: ~azure.mgmt.authorization.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,25 +90,21 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -116,17 +113,15 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertCo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertConfiguration", pipeline_response) + deserialized = self._deserialize("AlertConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return deserialized # type: ignore @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, scope: str, alert_id: str, @@ -142,19 +137,18 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration + :type parameters: ~azure.mgmt.authorization.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + async def update( + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. @@ -163,19 +157,18 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any + async def update( + self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO[bytes]], **kwargs: Any ) -> None: """Update an alert configuration. @@ -184,17 +177,13 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type - or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.AlertConfiguration or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -205,9 +194,7 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -219,23 +206,21 @@ async def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "AlertConfiguration") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -245,31 +230,26 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertConfiguration"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -280,33 +260,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) @@ -316,11 +282,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,5 +297,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_definitions_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_definitions_operations.py index 2b61202b6850..3aac2160d870 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +20,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._alert_definitions_operations import build_get_request, build_list_for_scope_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +41,7 @@ class AlertDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ @@ -48,11 +49,12 @@ class AlertDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: @@ -68,12 +70,11 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition + :rtype: ~azure.mgmt.authorization.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,25 +85,21 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -111,38 +108,31 @@ async def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _mod map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertDefinition", pipeline_response) + deserialized = self._deserialize("AlertDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" - } + return deserialized # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.AlertDefinition"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -153,33 +143,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) @@ -189,11 +165,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,5 +180,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_incidents_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_incidents_operations.py index 8d81b33abf64..1c5c50b74b65 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_incidents_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_incidents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._alert_incidents_operations import ( build_get_request, build_list_for_scope_request, build_remediate_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +45,7 @@ class AlertIncidentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ @@ -52,11 +53,12 @@ class AlertIncidentsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: @@ -74,12 +76,11 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident + :rtype: ~azure.mgmt.authorization.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,26 +91,22 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,40 +115,32 @@ async def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertIncident", pipeline_response) + deserialized = self._deserialize("AlertIncident", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" - } + return deserialized # type: ignore @distributed_trace - def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterable["_models.AlertIncident"]: + def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncItemPaged["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,34 +151,20 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncItera def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) @@ -199,11 +174,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,14 +190,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" - } - @distributed_trace_async - async def remediate( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any - ) -> None: + async def remediate(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> None: """Remediate an alert incident. :param scope: The scope of the alert incident. Required. @@ -231,12 +200,11 @@ async def remediate( # pylint: disable=inconsistent-return-statements :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,26 +215,22 @@ async def remediate( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_remediate_request( + _request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,8 +240,4 @@ async def remediate( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - remediate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_operation_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_operation_operations.py index 66abb7247b37..c24865e9d9fb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alert_operation_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alert_operation_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._alert_operation_operations import build_get_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,7 +38,7 @@ class AlertOperationOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ @@ -45,11 +46,12 @@ class AlertOperationOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: @@ -59,12 +61,11 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult + :rtype: ~azure.mgmt.authorization.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -75,25 +76,21 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -102,11 +99,9 @@ async def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.Ale map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alerts_operations.py similarity index 65% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alerts_operations.py index 309ec8b6fca5..e0211544dba6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_alerts_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_alerts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -import urllib.parse +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._alerts_operations import ( build_get_request, build_list_for_scope_request, @@ -38,6 +40,7 @@ build_refresh_request, build_update_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +52,7 @@ class AlertsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ @@ -57,11 +60,12 @@ class AlertsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: @@ -76,12 +80,11 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert + :rtype: ~azure.mgmt.authorization.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,25 +95,21 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,17 +118,15 @@ async def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Alert", pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return deserialized # type: ignore @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, scope: str, alert_id: str, @@ -145,19 +142,18 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert + :type parameters: ~azure.mgmt.authorization.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + async def update( + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. @@ -166,19 +162,18 @@ async def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any + async def update( + self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO[bytes]], **kwargs: Any ) -> None: """Update an alert. @@ -186,17 +181,14 @@ async def update( # pylint: disable=inconsistent-return-statements :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str - :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Parameters for the alert. Is either a Alert type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.authorization.models.Alert or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,9 +199,7 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -221,23 +211,21 @@ async def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "Alert") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,31 +235,25 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Alert"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,33 +264,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Al def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) @@ -318,11 +286,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -334,10 +302,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} - - async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,46 +314,43 @@ async def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_initial.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return deserialized # type: ignore @distributed_trace_async async def begin_refresh( @@ -399,26 +362,16 @@ async def begin_refresh( :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -433,6 +386,7 @@ async def begin_refresh( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -440,9 +394,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -454,20 +408,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return AsyncLROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,43 +430,42 @@ async def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.Alert _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_all_request( + _request = build_refresh_all_request( scope=scope, api_version=api_version, - template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return deserialized # type: ignore @distributed_trace_async async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_models.AlertOperationResult]: @@ -522,26 +473,16 @@ async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_ :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either AlertOperationResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.authorization.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -550,6 +491,7 @@ async def begin_refresh_all(self, scope: str, **kwargs: Any) -> AsyncLROPoller[_ raw_result = await self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -557,9 +499,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -571,12 +513,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return AsyncLROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_classic_administrators_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_classic_administrators_operations.py index 2ff0577ad8a4..3fb1e1aead09 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_classic_administrators_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._classic_administrators_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ class ClassicAdministratorsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ @@ -47,30 +47,30 @@ class ClassicAdministratorsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,33 +81,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -117,11 +103,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +119,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_deny_assignments_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_deny_assignments_operations.py index 11bc2ef51898..f450c6f3b846 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_deny_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._deny_assignments_operations import ( build_get_by_id_request, build_get_request, @@ -36,6 +35,7 @@ build_list_for_scope_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +47,7 @@ class DenyAssignmentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ @@ -55,11 +55,12 @@ class DenyAssignmentsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_resource( @@ -71,7 +72,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: + ) -> AsyncItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -96,19 +97,18 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,7 +119,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -128,30 +128,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -161,11 +147,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -178,14 +164,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: + ) -> AsyncItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -202,19 +184,18 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,35 +206,21 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -263,11 +230,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,12 +247,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny @@ -299,19 +262,18 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -322,34 +284,20 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -359,11 +307,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -376,8 +324,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace_async async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -386,12 +332,11 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment + :rtype: ~azure.mgmt.authorization.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -402,23 +347,21 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -428,14 +371,12 @@ async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace_async async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -447,12 +388,11 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment + :rtype: ~azure.mgmt.authorization.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,22 +403,20 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,19 +426,17 @@ async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: + ) -> AsyncItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. @@ -516,19 +452,18 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -539,34 +474,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -576,11 +497,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -592,5 +513,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_eligible_child_resources_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_eligible_child_resources_operations.py index 474a0ebb9741..6479c05fa783 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_eligible_child_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._eligible_child_resources_operations import build_get_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ class EligibleChildResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ @@ -47,16 +47,17 @@ class EligibleChildResourcesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EligibleChildResource"]: + ) -> AsyncItemPaged["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. @@ -66,20 +67,19 @@ def get( $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -90,34 +90,20 @@ def get( def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -127,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_global_administrator_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_global_administrator_operations.py index 0c066f8be930..d7ffefcf7bfa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_global_administrator_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._global_administrator_operations import build_elevate_access_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,7 +38,7 @@ class GlobalAdministratorOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`global_administrator` attribute. """ @@ -45,22 +46,22 @@ class GlobalAdministratorOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + async def elevate_access(self, **kwargs: Any) -> None: """Elevates access for a Global Administrator. - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -71,21 +72,19 @@ async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_elevate_access_request( + _request = build_elevate_access_request( api_version=api_version, - template_url=self.elevate_access.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -96,6 +95,4 @@ async def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=incons raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - elevate_access.metadata = {"url": "/providers/Microsoft.Authorization/elevateAccess"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_operations.py similarity index 57% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_operations.py index 8b130fe18976..797a29412b8b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ @@ -47,31 +47,28 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists the operations available from this provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,32 +79,18 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -117,11 +100,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +116,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_patch.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_patch.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_patch.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_permissions_operations.py similarity index 62% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_permissions_operations.py index f7dc7c98768f..1df402133be2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_permissions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +19,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ class PermissionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ @@ -47,32 +47,31 @@ class PermissionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: + def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,34 +82,20 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -120,11 +105,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +122,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -150,7 +131,7 @@ def list_for_resource( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Permission"]: + ) -> AsyncItemPaged["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -164,19 +145,17 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +166,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -195,30 +174,16 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -228,11 +193,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,7 +209,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_provider_operations_metadata_operations.py similarity index 65% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_provider_operations_metadata_operations.py index 364a0a8c192c..8227cf1e9fcb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +19,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._provider_operations_metadata_operations import build_get_request, build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ class ProviderOperationsMetadataOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`provider_operations_metadata` attribute. """ @@ -48,11 +48,12 @@ class ProviderOperationsMetadataOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -64,12 +65,11 @@ async def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata + :rtype: ~azure.mgmt.authorization.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,23 +80,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,35 +104,34 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: + def list( + self, expand: str = "resourceTypes", **kwargs: Any + ) -> AsyncItemPaged["_models.ProviderOperationsMetadata"]: """Gets provider operations metadata for all resource providers. :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderOperationsMetadata or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.ProviderOperationsMetadata] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -145,33 +142,19 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_ def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -181,11 +164,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,5 +180,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_instances_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_instances_operations.py index ebcb4e78ea7f..84aa089e22cf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,28 +19,28 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ @@ -48,16 +48,17 @@ class RoleAssignmentScheduleInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleInstance"]: + ) -> AsyncItemPaged["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. @@ -69,20 +70,19 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,34 +93,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -130,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,8 +132,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -159,12 +143,11 @@ async def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,23 +158,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -200,13 +181,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_requests_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_requests_operations.py index 0ae5c5d9a086..6a15b1a4a92a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_assignment_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -36,6 +36,7 @@ build_list_for_scope_request, build_validate_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ class RoleAssignmentScheduleRequestsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ @@ -55,11 +56,12 @@ class RoleAssignmentScheduleRequestsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def create( @@ -84,13 +86,12 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -99,7 +100,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,13 +118,12 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -132,7 +132,7 @@ async def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -148,18 +148,13 @@ async def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +165,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) @@ -182,23 +177,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,16 +200,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -229,12 +218,11 @@ async def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,23 +233,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,21 +256,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleRequest"]: + ) -> AsyncItemPaged["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. @@ -297,20 +279,19 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,34 +302,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -358,11 +325,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -374,12 +341,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> None: + async def cancel(self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. Required. @@ -387,12 +350,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,23 +365,21 @@ async def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,11 +389,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -453,13 +409,12 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -468,7 +423,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -481,13 +436,12 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -496,7 +450,7 @@ async def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -507,18 +461,13 @@ async def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +478,7 @@ async def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) @@ -541,23 +490,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,13 +513,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedules_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedules_operations.py index b3250239af59..638edf685377 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +19,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ class RoleAssignmentSchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ @@ -48,11 +48,12 @@ class RoleAssignmentSchedulesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -65,12 +66,11 @@ async def get( :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,23 +81,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,21 +104,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentSchedule"]: + ) -> AsyncItemPaged["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. @@ -132,20 +126,19 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,34 +149,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -193,11 +172,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,5 +187,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignments_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignments_operations.py index b6070feb7f78..3fa81ec75c51 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_assignments_operations import ( build_create_by_id_request, build_create_request, @@ -41,6 +41,7 @@ build_list_for_scope_request, build_list_for_subscription_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ class RoleAssignmentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ @@ -60,16 +61,17 @@ class RoleAssignmentsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: + ) -> AsyncItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role @@ -78,19 +80,18 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,35 +102,21 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -139,11 +126,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,14 +143,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: + ) -> AsyncItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -175,19 +158,18 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,36 +180,22 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -237,11 +205,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,10 +222,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -268,7 +232,7 @@ def list_for_resource( filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: + ) -> AsyncItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -287,19 +251,18 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,7 +273,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -319,30 +282,16 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -352,11 +301,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,10 +318,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -390,12 +335,11 @@ async def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,24 +350,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,14 +375,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload async def create( @@ -464,13 +404,12 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -479,7 +418,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -496,13 +435,12 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -511,7 +449,7 @@ async def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -526,18 +464,13 @@ async def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters or IO[bytes] :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -548,7 +481,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) @@ -560,23 +493,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -586,19 +517,13 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -616,12 +541,11 @@ async def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None + :rtype: ~azure.mgmt.authorization.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -632,24 +556,22 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -661,14 +583,12 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -678,7 +598,7 @@ def list_for_scope( tenant_id: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: + ) -> AsyncItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -697,19 +617,18 @@ def list_for_scope( return paged role assignments following the skipToken passed. Only supported on provider level calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,36 +639,22 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -759,11 +664,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -776,8 +681,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace_async async def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -787,17 +690,17 @@ async def get_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -808,23 +711,21 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -834,14 +735,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload async def create_by_id( @@ -857,68 +756,67 @@ async def create_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters or IO[bytes] :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,7 +827,7 @@ async def create_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) @@ -941,22 +839,20 @@ async def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -966,19 +862,13 @@ async def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -988,17 +878,17 @@ async def delete_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None + :rtype: ~azure.mgmt.authorization.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1009,23 +899,21 @@ async def delete_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1037,11 +925,9 @@ async def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_definitions_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_definitions_operations.py index e29e62d7fb75..05937eaeef12 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +36,7 @@ build_get_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +48,7 @@ class RoleDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ @@ -55,11 +56,12 @@ class RoleDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: @@ -73,12 +75,11 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None + :rtype: ~azure.mgmt.authorization.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,25 +90,21 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,14 +116,12 @@ async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Op deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -140,12 +135,11 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,25 +150,21 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,14 +174,12 @@ async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload async def create_or_update( @@ -214,13 +202,12 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :type role_definition: ~azure.mgmt.authorization.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -229,7 +216,7 @@ async def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -245,19 +232,22 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -270,18 +260,13 @@ async def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,9 +277,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) @@ -306,23 +289,21 @@ async def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,17 +313,15 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: + def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -354,21 +333,18 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -379,34 +355,20 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Async def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -416,11 +378,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,8 +395,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -445,12 +405,11 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -461,24 +420,20 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,11 +443,9 @@ async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_instances_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_instances_operations.py index dab77c986c6a..987e7c0fbf96 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,31 +19,31 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_eligibility_schedule_instances_operations import ( build_get_request, build_list_for_scope_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ @@ -51,16 +51,17 @@ class RoleEligibilityScheduleInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleInstance"]: + ) -> AsyncItemPaged["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. @@ -72,20 +73,19 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,34 +96,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -133,11 +119,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,8 +135,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -162,12 +146,11 @@ async def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,23 +161,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,13 +184,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_requests_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_requests_operations.py index 384a66bed66e..f19f550dbecd 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, @@ -36,18 +36,19 @@ build_list_for_scope_request, build_validate_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ @@ -55,11 +56,12 @@ class RoleEligibilityScheduleRequestsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def create( @@ -84,13 +86,12 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -99,7 +100,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,13 +118,12 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -132,7 +132,7 @@ async def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -148,18 +148,13 @@ async def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,7 +165,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) @@ -182,23 +177,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,16 +200,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -229,12 +218,11 @@ async def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,23 +233,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,21 +256,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleRequest"]: + ) -> AsyncItemPaged["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. @@ -297,20 +279,19 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -321,34 +302,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -358,11 +325,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -374,12 +341,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> None: + async def cancel(self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. Required. @@ -387,12 +350,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,23 +365,21 @@ async def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,11 +389,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def validate( @@ -453,13 +409,12 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -468,7 +423,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -481,13 +436,12 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -496,7 +450,7 @@ async def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -507,18 +461,13 @@ async def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -529,7 +478,7 @@ async def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) @@ -541,23 +490,21 @@ async def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,13 +513,9 @@ async def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedules_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedules_operations.py index beeb9ff0e6db..a1073e1991b2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,16 +19,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ class RoleEligibilitySchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ @@ -48,11 +48,12 @@ class RoleEligibilitySchedulesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -65,12 +66,11 @@ async def get( :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule + :rtype: ~azure.mgmt.authorization.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,23 +81,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,21 +104,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilitySchedule"]: + ) -> AsyncItemPaged["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. @@ -132,20 +126,19 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,34 +149,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -193,11 +172,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,5 +187,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policies_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policies_operations.py index 24d48258e4e8..b9c2021eec9b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,21 +20,21 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_management_policies_operations import ( build_delete_request, build_get_request, build_list_for_scope_request, build_update_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +46,7 @@ class RoleManagementPoliciesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ @@ -54,11 +54,12 @@ class RoleManagementPoliciesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: @@ -69,12 +70,11 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,23 +85,21 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,16 +108,12 @@ async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload async def update( @@ -139,13 +133,12 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @@ -154,7 +147,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -167,13 +160,12 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @@ -182,7 +174,7 @@ async def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -193,17 +185,13 @@ async def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicy or IO[bytes] :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -214,7 +202,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) @@ -226,23 +214,21 @@ async def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -251,21 +237,15 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_name: str, **kwargs: Any - ) -> None: + async def delete(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. Required. @@ -273,12 +253,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,23 +268,21 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -315,32 +292,27 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -351,33 +323,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -387,11 +345,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -402,5 +360,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policy_assignments_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policy_assignments_operations.py index c0d93ed66a45..41a86ac1ba7f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,33 +20,33 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._role_management_policy_assignments_operations import ( build_create_request, build_delete_request, build_get_request, build_list_for_scope_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ @@ -54,11 +54,12 @@ class RoleManagementPolicyAssignmentsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -71,12 +72,11 @@ async def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,23 +87,21 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,16 +110,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload async def create( @@ -141,13 +135,12 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -156,7 +149,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -169,13 +162,12 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -184,7 +176,7 @@ async def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -195,18 +187,13 @@ async def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment or IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,7 +204,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) @@ -229,23 +216,21 @@ async def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,21 +239,15 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> None: + async def delete(self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. Required. @@ -276,12 +255,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,23 +270,21 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -318,32 +294,27 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncItemPaged["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,33 +325,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Ro def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -390,11 +347,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -405,5 +362,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_default_settings_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_default_settings_operations.py index 3cf432e09ae3..c278e4946556 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_default_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_default_settings_operations import build_get_request, build_put_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewDefaultSettingsOperations: +class ScopeAccessReviewDefaultSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ @@ -46,11 +47,12 @@ class ScopeAccessReviewDefaultSettingsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: @@ -58,12 +60,11 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -74,24 +75,20 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -101,14 +98,12 @@ async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSet error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore @overload async def put( @@ -124,57 +119,49 @@ async def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( - self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( - self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,9 +172,7 @@ async def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) @@ -199,22 +184,20 @@ async def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,11 +207,9 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instance_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instance_operations.py index 3d5583c15b4f..ca72af3eb3f5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instance_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,29 +18,29 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_history_definition_instance_operations import ( build_generate_download_uri_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionInstanceOperations: +class ScopeAccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ @@ -47,11 +48,12 @@ class ScopeAccessReviewHistoryDefinitionInstanceOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def generate_download_uri( @@ -67,12 +69,11 @@ async def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,26 +84,22 @@ async def generate_download_uri( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,13 +109,9 @@ async def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_download_uri.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instances_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instances_operations.py index b08d5b0de42e..444e7eecfe51 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_history_definition_instances_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionInstancesOperations: +class ScopeAccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ @@ -47,38 +47,36 @@ class ScopeAccessReviewHistoryDefinitionInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: + ) -> AsyncItemPaged["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,34 +87,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -126,11 +110,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +126,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_operations.py index 051a192ce530..d4203f691cca 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definition_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,30 +19,30 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_history_definition_operations import ( build_create_request, build_delete_by_id_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionOperations: +class ScopeAccessReviewHistoryDefinitionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ @@ -49,11 +50,12 @@ class ScopeAccessReviewHistoryDefinitionOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def create( @@ -72,14 +74,12 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -88,7 +88,7 @@ async def create( self, scope: str, history_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -100,13 +100,12 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -115,7 +114,7 @@ async def create( self, scope: str, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -125,19 +124,14 @@ async def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties or + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,9 +142,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) @@ -162,23 +154,21 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -188,33 +178,26 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, scope: str, history_definition_id: str, **kwargs: Any - ) -> None: + async def delete_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> None: """Delete an access review history definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,25 +208,21 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,8 +233,4 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definitions_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definitions_operations.py index a3756ba1f04a..baf6416b0bfa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_history_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,31 +19,31 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_history_definitions_operations import ( build_get_by_id_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewHistoryDefinitionsOperations: +class ScopeAccessReviewHistoryDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ @@ -51,16 +51,17 @@ class ScopeAccessReviewHistoryDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewHistoryDefinition"]: + ) -> AsyncItemPaged["_models.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. @@ -69,22 +70,19 @@ def list( :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,34 +93,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -132,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,8 +133,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions"} - @distributed_trace_async async def get_by_id( self, scope: str, history_definition_id: str, **kwargs: Any @@ -161,12 +143,11 @@ async def get_by_id( :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,25 +158,21 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,13 +182,9 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py index 633523af6d35..bb19da3921a6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_instance_contacted_reviewers_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewInstanceContactedReviewersOperations: +class ScopeAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ @@ -47,16 +47,17 @@ class ScopeAccessReviewInstanceContactedReviewersOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: + ) -> AsyncItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. @@ -65,22 +66,19 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,35 +89,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -129,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,7 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_decisions_operations.py similarity index 63% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_decisions_operations.py index be677521f8c8..bcbfca9a6d46 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_decisions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_instance_decisions_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewInstanceDecisionsOperations: +class ScopeAccessReviewInstanceDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ @@ -47,16 +47,17 @@ class ScopeAccessReviewInstanceDecisionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: + ) -> AsyncItemPaged["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. @@ -70,22 +71,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,36 +94,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -135,11 +119,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,7 +135,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_operations.py index 69703cba78d3..fcaf40797faa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instance_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_instance_operations import ( build_apply_decisions_request, build_record_all_decisions_request, @@ -33,6 +33,7 @@ build_send_reminders_request, build_stop_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +45,7 @@ class ScopeAccessReviewInstanceOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ @@ -52,16 +53,15 @@ class ScopeAccessReviewInstanceOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def stop(self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to stop an access review instance. :param scope: The scope of the resource. Required. @@ -70,12 +70,11 @@ async def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +85,22 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -116,14 +111,10 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @overload - async def record_all_decisions( # pylint: disable=inconsistent-return-statements + async def record_all_decisions( self, scope: str, schedule_definition_id: str, @@ -142,24 +133,22 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties + :type properties: ~azure.mgmt.authorization.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def record_all_decisions( # pylint: disable=inconsistent-return-statements + async def record_all_decisions( self, scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -173,23 +162,22 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def record_all_decisions( # pylint: disable=inconsistent-return-statements + async def record_all_decisions( self, scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.RecordAllDecisionsProperties, IO], + properties: Union[_models.RecordAllDecisionsProperties, IO[bytes]], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. @@ -201,18 +189,13 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type - or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.RecordAllDecisionsProperties or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -223,9 +206,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -237,7 +218,7 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") - request = build_record_all_decisions_request( + _request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -245,16 +226,14 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, content=_content, - template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -265,16 +244,10 @@ async def record_all_decisions( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - record_all_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def reset_decisions( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def reset_decisions(self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to reset all decisions for an access review instance. :param scope: The scope of the resource. Required. @@ -283,12 +256,11 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,26 +271,22 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -329,16 +297,10 @@ async def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def apply_decisions( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def apply_decisions(self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to apply all decisions for an access review instance. :param scope: The scope of the resource. Required. @@ -347,12 +309,11 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,26 +324,22 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +350,10 @@ async def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def send_reminders( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: + async def send_reminders(self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> None: """An action to send reminders for an access review instance. :param scope: The scope of the resource. Required. @@ -411,12 +362,11 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,26 +377,22 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -457,8 +403,4 @@ async def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instances_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instances_operations.py index 098e7b1ea1af..6034492a2a54 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,20 +20,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +45,7 @@ class ScopeAccessReviewInstancesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ @@ -53,16 +53,17 @@ class ScopeAccessReviewInstancesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: + ) -> AsyncItemPaged["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. @@ -74,22 +75,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,35 +98,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -138,11 +122,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +139,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any @@ -171,12 +151,11 @@ async def get_by_id( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,26 +166,22 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,16 +191,12 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload async def create( @@ -247,14 +218,12 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -264,7 +233,7 @@ async def create( scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,13 +247,12 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -294,7 +262,7 @@ async def create( scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -306,18 +274,13 @@ async def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewInstanceProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties or IO[bytes] :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,9 +291,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) @@ -342,7 +303,7 @@ async def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -350,16 +311,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,13 +328,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_schedule_definitions_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_schedule_definitions_operations.py index dd70ad66685a..e3a374e0c67e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_scope_access_review_schedule_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,15 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._scope_access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, @@ -36,18 +35,19 @@ build_list_request, build_stop_request, ) +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScopeAccessReviewScheduleDefinitionsOperations: +class ScopeAccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ @@ -55,16 +55,17 @@ class ScopeAccessReviewScheduleDefinitionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: + ) -> AsyncItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. @@ -74,22 +75,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,34 +98,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -137,11 +121,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,8 +138,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} - @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any @@ -166,12 +148,11 @@ async def get_by_id( :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -182,25 +163,21 @@ async def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,33 +187,26 @@ async def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, **kwargs: Any - ) -> None: + async def delete_by_id(self, scope: str, schedule_definition_id: str, **kwargs: Any) -> None: """Delete access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,25 +217,21 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,11 +242,7 @@ async def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def create_or_update_by_id( @@ -299,14 +261,12 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -315,7 +275,7 @@ async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -327,13 +287,12 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -342,7 +301,7 @@ async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -352,19 +311,14 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties or + IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,9 +329,7 @@ async def create_or_update_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) @@ -389,23 +341,21 @@ async def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -415,33 +365,26 @@ async def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, scope: str, schedule_definition_id: str, **kwargs: Any - ) -> None: + async def stop(self, scope: str, schedule_definition_id: str, **kwargs: Any) -> None: """Stop access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,25 +395,21 @@ async def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -481,8 +420,4 @@ async def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index a4616c3cfbc9..a75cf778c29a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,27 +19,27 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request +from .._configuration import AuthorizationManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.aio.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ @@ -47,38 +47,36 @@ class TenantLevelAccessReviewInstanceContactedReviewersOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: + ) -> AsyncItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,34 +87,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -126,11 +110,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +126,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py deleted file mode 100644 index d83931c49191..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py +++ /dev/null @@ -1,12 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from .v2015_07_01.models import * -from .v2019_08_01_preview.models import * -from .v2020_10_01.models import * -from .v2021_01_01_preview.models import * -from .v2021_12_01_preview.models import * -from .v2022_04_01.models import * diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/__init__.py new file mode 100644 index 000000000000..e1682310589b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/__init__.py @@ -0,0 +1,360 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AccessReviewContactedReviewer, + AccessReviewContactedReviewerListResult, + AccessReviewDecision, + AccessReviewDecisionIdentity, + AccessReviewDecisionInsight, + AccessReviewDecisionInsightProperties, + AccessReviewDecisionListResult, + AccessReviewDecisionProperties, + AccessReviewDecisionServicePrincipalIdentity, + AccessReviewDecisionUserIdentity, + AccessReviewDecisionUserSignInInsightProperties, + AccessReviewDefaultSettings, + AccessReviewHistoryDefinition, + AccessReviewHistoryDefinitionInstanceListResult, + AccessReviewHistoryDefinitionListResult, + AccessReviewHistoryDefinitionProperties, + AccessReviewHistoryInstance, + AccessReviewInstance, + AccessReviewInstanceListResult, + AccessReviewInstanceProperties, + AccessReviewReviewer, + AccessReviewScheduleDefinition, + AccessReviewScheduleDefinitionListResult, + AccessReviewScheduleDefinitionProperties, + AccessReviewScheduleSettings, + AccessReviewScope, + Alert, + AlertConfiguration, + AlertConfigurationListResult, + AlertConfigurationProperties, + AlertDefinition, + AlertDefinitionListResult, + AlertIncident, + AlertIncidentListResult, + AlertIncidentProperties, + AlertListResult, + AlertOperationResult, + ApprovalSettings, + ApprovalStage, + AzureRolesAssignedOutsidePimAlertConfigurationProperties, + AzureRolesAssignedOutsidePimAlertIncidentProperties, + ClassicAdministrator, + ClassicAdministratorListResult, + CloudErrorBody, + DenyAssignment, + DenyAssignmentFilter, + DenyAssignmentListResult, + DenyAssignmentPermission, + DuplicateRoleCreatedAlertConfigurationProperties, + DuplicateRoleCreatedAlertIncidentProperties, + EligibleChildResource, + EligibleChildResourcesListResult, + ErrorAdditionalInfo, + ErrorDefinition, + ErrorDefinitionProperties, + ErrorDetail, + ErrorResponse, + ExpandedProperties, + ExpandedPropertiesPrincipal, + ExpandedPropertiesRoleDefinition, + ExpandedPropertiesScope, + Operation, + OperationDisplay, + OperationListResult, + PIMOnlyModeSettings, + Permission, + PermissionGetResult, + PolicyAssignmentProperties, + PolicyAssignmentPropertiesPolicy, + PolicyAssignmentPropertiesRoleDefinition, + PolicyAssignmentPropertiesScope, + PolicyProperties, + PolicyPropertiesScope, + Principal, + ProviderOperation, + ProviderOperationsMetadata, + ProviderOperationsMetadataListResult, + RecordAllDecisionsProperties, + ResourceType, + RoleAssignment, + RoleAssignmentCreateParameters, + RoleAssignmentFilter, + RoleAssignmentListResult, + RoleAssignmentSchedule, + RoleAssignmentScheduleFilter, + RoleAssignmentScheduleInstance, + RoleAssignmentScheduleInstanceFilter, + RoleAssignmentScheduleInstanceListResult, + RoleAssignmentScheduleListResult, + RoleAssignmentScheduleRequest, + RoleAssignmentScheduleRequestFilter, + RoleAssignmentScheduleRequestListResult, + RoleAssignmentScheduleRequestPropertiesScheduleInfo, + RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, + RoleAssignmentScheduleRequestPropertiesTicketInfo, + RoleDefinition, + RoleDefinitionFilter, + RoleDefinitionListResult, + RoleEligibilitySchedule, + RoleEligibilityScheduleFilter, + RoleEligibilityScheduleInstance, + RoleEligibilityScheduleInstanceFilter, + RoleEligibilityScheduleInstanceListResult, + RoleEligibilityScheduleListResult, + RoleEligibilityScheduleRequest, + RoleEligibilityScheduleRequestFilter, + RoleEligibilityScheduleRequestListResult, + RoleEligibilityScheduleRequestPropertiesScheduleInfo, + RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, + RoleEligibilityScheduleRequestPropertiesTicketInfo, + RoleManagementPolicy, + RoleManagementPolicyApprovalRule, + RoleManagementPolicyAssignment, + RoleManagementPolicyAssignmentListResult, + RoleManagementPolicyAuthenticationContextRule, + RoleManagementPolicyEnablementRule, + RoleManagementPolicyExpirationRule, + RoleManagementPolicyListResult, + RoleManagementPolicyNotificationRule, + RoleManagementPolicyPimOnlyModeRule, + RoleManagementPolicyRule, + RoleManagementPolicyRuleTarget, + TooManyOwnersAssignedToResourceAlertConfigurationProperties, + TooManyOwnersAssignedToResourceAlertIncidentProperties, + TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties, + TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties, + UserSet, + UsersOrServicePrincipalSet, + ValidationResponse, + ValidationResponseErrorInfo, +) + +from ._authorization_management_client_enums import ( # type: ignore + AccessRecommendationType, + AccessReviewActorIdentityType, + AccessReviewApplyResult, + AccessReviewDecisionInsightType, + AccessReviewDecisionPrincipalResourceMembershipType, + AccessReviewHistoryDefinitionStatus, + AccessReviewInstanceReviewersType, + AccessReviewInstanceStatus, + AccessReviewRecurrencePatternType, + AccessReviewRecurrenceRangeType, + AccessReviewResult, + AccessReviewReviewerType, + AccessReviewScheduleDefinitionReviewersType, + AccessReviewScheduleDefinitionStatus, + AccessReviewScopeAssignmentState, + AccessReviewScopePrincipalType, + ApprovalMode, + AssignmentType, + DecisionResourceType, + DecisionTargetType, + DefaultDecisionType, + EnablementRules, + ExcludedPrincipalTypes, + MemberType, + NotificationDeliveryMechanism, + NotificationLevel, + PIMOnlyMode, + PrincipalType, + RecipientType, + RecordAllDecisionsResult, + RequestType, + RoleManagementPolicyRuleType, + SeverityLevel, + Status, + Type, + UserType, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AccessReviewContactedReviewer", + "AccessReviewContactedReviewerListResult", + "AccessReviewDecision", + "AccessReviewDecisionIdentity", + "AccessReviewDecisionInsight", + "AccessReviewDecisionInsightProperties", + "AccessReviewDecisionListResult", + "AccessReviewDecisionProperties", + "AccessReviewDecisionServicePrincipalIdentity", + "AccessReviewDecisionUserIdentity", + "AccessReviewDecisionUserSignInInsightProperties", + "AccessReviewDefaultSettings", + "AccessReviewHistoryDefinition", + "AccessReviewHistoryDefinitionInstanceListResult", + "AccessReviewHistoryDefinitionListResult", + "AccessReviewHistoryDefinitionProperties", + "AccessReviewHistoryInstance", + "AccessReviewInstance", + "AccessReviewInstanceListResult", + "AccessReviewInstanceProperties", + "AccessReviewReviewer", + "AccessReviewScheduleDefinition", + "AccessReviewScheduleDefinitionListResult", + "AccessReviewScheduleDefinitionProperties", + "AccessReviewScheduleSettings", + "AccessReviewScope", + "Alert", + "AlertConfiguration", + "AlertConfigurationListResult", + "AlertConfigurationProperties", + "AlertDefinition", + "AlertDefinitionListResult", + "AlertIncident", + "AlertIncidentListResult", + "AlertIncidentProperties", + "AlertListResult", + "AlertOperationResult", + "ApprovalSettings", + "ApprovalStage", + "AzureRolesAssignedOutsidePimAlertConfigurationProperties", + "AzureRolesAssignedOutsidePimAlertIncidentProperties", + "ClassicAdministrator", + "ClassicAdministratorListResult", + "CloudErrorBody", + "DenyAssignment", + "DenyAssignmentFilter", + "DenyAssignmentListResult", + "DenyAssignmentPermission", + "DuplicateRoleCreatedAlertConfigurationProperties", + "DuplicateRoleCreatedAlertIncidentProperties", + "EligibleChildResource", + "EligibleChildResourcesListResult", + "ErrorAdditionalInfo", + "ErrorDefinition", + "ErrorDefinitionProperties", + "ErrorDetail", + "ErrorResponse", + "ExpandedProperties", + "ExpandedPropertiesPrincipal", + "ExpandedPropertiesRoleDefinition", + "ExpandedPropertiesScope", + "Operation", + "OperationDisplay", + "OperationListResult", + "PIMOnlyModeSettings", + "Permission", + "PermissionGetResult", + "PolicyAssignmentProperties", + "PolicyAssignmentPropertiesPolicy", + "PolicyAssignmentPropertiesRoleDefinition", + "PolicyAssignmentPropertiesScope", + "PolicyProperties", + "PolicyPropertiesScope", + "Principal", + "ProviderOperation", + "ProviderOperationsMetadata", + "ProviderOperationsMetadataListResult", + "RecordAllDecisionsProperties", + "ResourceType", + "RoleAssignment", + "RoleAssignmentCreateParameters", + "RoleAssignmentFilter", + "RoleAssignmentListResult", + "RoleAssignmentSchedule", + "RoleAssignmentScheduleFilter", + "RoleAssignmentScheduleInstance", + "RoleAssignmentScheduleInstanceFilter", + "RoleAssignmentScheduleInstanceListResult", + "RoleAssignmentScheduleListResult", + "RoleAssignmentScheduleRequest", + "RoleAssignmentScheduleRequestFilter", + "RoleAssignmentScheduleRequestListResult", + "RoleAssignmentScheduleRequestPropertiesScheduleInfo", + "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", + "RoleAssignmentScheduleRequestPropertiesTicketInfo", + "RoleDefinition", + "RoleDefinitionFilter", + "RoleDefinitionListResult", + "RoleEligibilitySchedule", + "RoleEligibilityScheduleFilter", + "RoleEligibilityScheduleInstance", + "RoleEligibilityScheduleInstanceFilter", + "RoleEligibilityScheduleInstanceListResult", + "RoleEligibilityScheduleListResult", + "RoleEligibilityScheduleRequest", + "RoleEligibilityScheduleRequestFilter", + "RoleEligibilityScheduleRequestListResult", + "RoleEligibilityScheduleRequestPropertiesScheduleInfo", + "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", + "RoleEligibilityScheduleRequestPropertiesTicketInfo", + "RoleManagementPolicy", + "RoleManagementPolicyApprovalRule", + "RoleManagementPolicyAssignment", + "RoleManagementPolicyAssignmentListResult", + "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", + "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyListResult", + "RoleManagementPolicyNotificationRule", + "RoleManagementPolicyPimOnlyModeRule", + "RoleManagementPolicyRule", + "RoleManagementPolicyRuleTarget", + "TooManyOwnersAssignedToResourceAlertConfigurationProperties", + "TooManyOwnersAssignedToResourceAlertIncidentProperties", + "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", + "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", + "UserSet", + "UsersOrServicePrincipalSet", + "ValidationResponse", + "ValidationResponseErrorInfo", + "AccessRecommendationType", + "AccessReviewActorIdentityType", + "AccessReviewApplyResult", + "AccessReviewDecisionInsightType", + "AccessReviewDecisionPrincipalResourceMembershipType", + "AccessReviewHistoryDefinitionStatus", + "AccessReviewInstanceReviewersType", + "AccessReviewInstanceStatus", + "AccessReviewRecurrencePatternType", + "AccessReviewRecurrenceRangeType", + "AccessReviewResult", + "AccessReviewReviewerType", + "AccessReviewScheduleDefinitionReviewersType", + "AccessReviewScheduleDefinitionStatus", + "AccessReviewScopeAssignmentState", + "AccessReviewScopePrincipalType", + "ApprovalMode", + "AssignmentType", + "DecisionResourceType", + "DecisionTargetType", + "DefaultDecisionType", + "EnablementRules", + "ExcludedPrincipalTypes", + "MemberType", + "NotificationDeliveryMechanism", + "NotificationLevel", + "PIMOnlyMode", + "PrincipalType", + "RecipientType", + "RecordAllDecisionsResult", + "RequestType", + "RoleManagementPolicyRuleType", + "SeverityLevel", + "Status", + "Type", + "UserType", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_authorization_management_client_enums.py similarity index 56% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_authorization_management_client_enums.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_authorization_management_client_enums.py index 521b3f817a6e..9cb46a417550 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_authorization_management_client_enums.py @@ -163,6 +163,22 @@ class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMet REDEEMED_GUEST_USER = "redeemedGuestUser" +class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of rule.""" + + SINGLE_STAGE = "SingleStage" + SERIAL = "Serial" + PARALLEL = "Parallel" + NO_APPROVAL = "NoApproval" + + +class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Assignment type of the role assignment schedule.""" + + ACTIVATED = "Activated" + ASSIGNED = "Assigned" + + class DecisionResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of resource.""" @@ -184,8 +200,147 @@ class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): RECOMMENDATION = "Recommendation" +class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of enablement rule.""" + + MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" + JUSTIFICATION = "Justification" + TICKETING = "Ticketing" + + +class ExcludedPrincipalTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExcludedPrincipalTypes.""" + + SERVICE_PRINCIPALS_AS_TARGET = "ServicePrincipalsAsTarget" + SERVICE_PRINCIPALS_AS_REQUESTOR = "ServicePrincipalsAsRequestor" + + +class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Membership type of the role assignment schedule.""" + + INHERITED = "Inherited" + DIRECT = "Direct" + GROUP = "Group" + + +class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of notification.""" + + EMAIL = "Email" + + +class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The notification level.""" + + NONE = "None" + CRITICAL = "Critical" + ALL = "All" + + +class PIMOnlyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Determines whether the setting is enabled, disabled or report only.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + REPORT_ONLY = "ReportOnly" + + +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The principal type of the assigned principal ID.""" + + USER = "User" + GROUP = "Group" + SERVICE_PRINCIPAL = "ServicePrincipal" + FOREIGN_GROUP = "ForeignGroup" + DEVICE = "Device" + + +class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The recipient type.""" + + REQUESTOR = "Requestor" + APPROVER = "Approver" + ADMIN = "Admin" + + class RecordAllDecisionsResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The decision to make. Approvers can take action of Approve/Deny.""" APPROVE = "Approve" DENY = "Deny" + + +class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" + + ADMIN_ASSIGN = "AdminAssign" + ADMIN_REMOVE = "AdminRemove" + ADMIN_UPDATE = "AdminUpdate" + ADMIN_EXTEND = "AdminExtend" + ADMIN_RENEW = "AdminRenew" + SELF_ACTIVATE = "SelfActivate" + SELF_DEACTIVATE = "SelfDeactivate" + SELF_EXTEND = "SelfExtend" + SELF_RENEW = "SelfRenew" + + +class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of rule.""" + + ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" + ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" + ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" + ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" + ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" + ROLE_MANAGEMENT_POLICY_PIM_ONLY_MODE_RULE = "RoleManagementPolicyPimOnlyModeRule" + + +class SeverityLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity level of the alert.""" + + LOW = "Low" + MEDIUM = "Medium" + HIGH = "High" + + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the role assignment schedule.""" + + ACCEPTED = "Accepted" + PENDING_EVALUATION = "PendingEvaluation" + GRANTED = "Granted" + DENIED = "Denied" + PENDING_PROVISIONING = "PendingProvisioning" + PROVISIONED = "Provisioned" + PENDING_REVOCATION = "PendingRevocation" + REVOKED = "Revoked" + CANCELED = "Canceled" + FAILED = "Failed" + PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" + PENDING_APPROVAL = "PendingApproval" + FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" + PENDING_ADMIN_DECISION = "PendingAdminDecision" + ADMIN_APPROVED = "AdminApproved" + ADMIN_DENIED = "AdminDenied" + TIMED_OUT = "TimedOut" + PROVISIONING_STARTED = "ProvisioningStarted" + INVALID = "Invalid" + PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" + SCHEDULE_CREATED = "ScheduleCreated" + PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the role assignment schedule expiration.""" + + AFTER_DURATION = "AfterDuration" + AFTER_DATE_TIME = "AfterDateTime" + NO_EXPIRATION = "NoExpiration" + + +class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of user.""" + + USER = "User" + GROUP = "Group" + SERVICE_PRINCIPAL = "ServicePrincipal" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_models_py3.py new file mode 100644 index 000000000000..82353fbf6216 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_models_py3.py @@ -0,0 +1,8222 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from collections.abc import MutableMapping +import datetime +from typing import Any, List, Optional, TYPE_CHECKING, Union + +from .._utils import serialization as _serialization + +if TYPE_CHECKING: + from .. import models as _models +JSON = MutableMapping[str, Any] + + +class AccessReviewContactedReviewer(_serialization.Model): + """Access Review Contacted Reviewer. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review reviewer id. + :vartype id: str + :ivar name: The access review reviewer id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar user_display_name: The display name of the reviewer. + :vartype user_display_name: str + :ivar user_principal_name: The user principal name of the reviewer. + :vartype user_principal_name: str + :ivar created_date_time: Date Time when the reviewer was contacted. + :vartype created_date_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "user_display_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + "created_date_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, + "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.user_display_name: Optional[str] = None + self.user_principal_name: Optional[str] = None + self.created_date_time: Optional[datetime.datetime] = None + + +class AccessReviewContactedReviewerListResult(_serialization.Model): + """List of access review contacted reviewers. + + :ivar value: Access Review Contacted Reviewer. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review Contacted Reviewer. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecision(_serialization.Model): + """Access Review. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review decision id. + :vartype id: str + :ivar name: The access review decision name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", and "NoInfoAvailable". + :vartype recommendation: str or ~azure.mgmt.authorization.models.AccessRecommendationType + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. + Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", + "DontKnow", and "NotNotified". + :vartype decision: str or ~azure.mgmt.authorization.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str + :ivar reviewed_date_time: Date Time when a decision was taken. + :vartype reviewed_date_time: ~datetime.datetime + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and + "ApplyNotSupported". + :vartype apply_result: str or ~azure.mgmt.authorization.models.AccessReviewApplyResult + :ivar applied_date_time: The date and time when the review decision was applied. + :vartype applied_date_time: ~datetime.datetime + :ivar insights: This is the collection of insights for this decision item. + :vartype insights: list[~azure.mgmt.authorization.models.AccessReviewDecisionInsight] + :ivar membership_types: Every decision item in an access review represents a principal's + membership to a resource. This property represents details of the membership. Examples of this + detail might be whether the principal has direct access or indirect access. + :vartype membership_types: list[str or + ~azure.mgmt.authorization.models.AccessReviewDecisionPrincipalResourceMembershipType] + :ivar principal_id_properties_applied_by_principal_id: The identity id. + :vartype principal_id_properties_applied_by_principal_id: str + :ivar principal_type_properties_applied_by_principal_type: The identity type : + user/servicePrincipal. Known values are: "user" and "servicePrincipal". + :vartype principal_type_properties_applied_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name_properties_applied_by_principal_name: The identity display name. + :vartype principal_name_properties_applied_by_principal_name: str + :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if + valid). + :vartype user_principal_name_properties_applied_by_user_principal_name: str + :ivar principal_id_properties_reviewed_by_principal_id: The identity id. + :vartype principal_id_properties_reviewed_by_principal_id: str + :ivar principal_type_properties_reviewed_by_principal_type: The identity type : + user/servicePrincipal. Known values are: "user" and "servicePrincipal". + :vartype principal_type_properties_reviewed_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. + :vartype principal_name_properties_reviewed_by_principal_name: str + :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal + name(if valid). + :vartype user_principal_name_properties_reviewed_by_user_principal_name: str + :ivar type_properties_resource_type: The type of resource. "azureRole" + :vartype type_properties_resource_type: str or + ~azure.mgmt.authorization.models.DecisionResourceType + :ivar id_properties_resource_id: The id of resource associated with a decision record. + :vartype id_properties_resource_id: str + :ivar display_name_properties_resource_display_name: The display name of resource associated + with a decision record. + :vartype display_name_properties_resource_display_name: str + :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. + Known values are: "user" and "servicePrincipal". + :vartype type_properties_principal_type: str or + ~azure.mgmt.authorization.models.DecisionTargetType + :ivar id_properties_principal_id: The id of principal whose access was reviewed. + :vartype id_properties_principal_id: str + :ivar display_name_properties_principal_display_name: The display name of the user whose access + was reviewed. + :vartype display_name_properties_principal_display_name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "recommendation": {"readonly": True}, + "reviewed_date_time": {"readonly": True}, + "apply_result": {"readonly": True}, + "applied_date_time": {"readonly": True}, + "principal_id_properties_applied_by_principal_id": {"readonly": True}, + "principal_type_properties_applied_by_principal_type": {"readonly": True}, + "principal_name_properties_applied_by_principal_name": {"readonly": True}, + "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, + "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, + "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, + "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, + "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, + "id_properties_resource_id": {"readonly": True}, + "display_name_properties_resource_display_name": {"readonly": True}, + "id_properties_principal_id": {"readonly": True}, + "display_name_properties_principal_display_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "recommendation": {"key": "properties.recommendation", "type": "str"}, + "decision": {"key": "properties.decision", "type": "str"}, + "justification": {"key": "properties.justification", "type": "str"}, + "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, + "apply_result": {"key": "properties.applyResult", "type": "str"}, + "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, + "insights": {"key": "properties.insights", "type": "[AccessReviewDecisionInsight]"}, + "membership_types": {"key": "properties.principalResourceMembership.membershipTypes", "type": "[str]"}, + "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, + "principal_type_properties_applied_by_principal_type": { + "key": "properties.appliedBy.principalType", + "type": "str", + }, + "principal_name_properties_applied_by_principal_name": { + "key": "properties.appliedBy.principalName", + "type": "str", + }, + "user_principal_name_properties_applied_by_user_principal_name": { + "key": "properties.appliedBy.userPrincipalName", + "type": "str", + }, + "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, + "principal_type_properties_reviewed_by_principal_type": { + "key": "properties.reviewedBy.principalType", + "type": "str", + }, + "principal_name_properties_reviewed_by_principal_name": { + "key": "properties.reviewedBy.principalName", + "type": "str", + }, + "user_principal_name_properties_reviewed_by_user_principal_name": { + "key": "properties.reviewedBy.userPrincipalName", + "type": "str", + }, + "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, + "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, + "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, + "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, + "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, + "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, + justification: Optional[str] = None, + insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, + membership_types: Optional[ + List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] + ] = None, + type_properties_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", + "NotReviewed", "DontKnow", and "NotNotified". + :paramtype decision: str or ~azure.mgmt.authorization.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + :keyword insights: This is the collection of insights for this decision item. + :paramtype insights: list[~azure.mgmt.authorization.models.AccessReviewDecisionInsight] + :keyword membership_types: Every decision item in an access review represents a principal's + membership to a resource. This property represents details of the membership. Examples of this + detail might be whether the principal has direct access or indirect access. + :paramtype membership_types: list[str or + ~azure.mgmt.authorization.models.AccessReviewDecisionPrincipalResourceMembershipType] + :keyword type_properties_resource_type: The type of resource. "azureRole" + :paramtype type_properties_resource_type: str or + ~azure.mgmt.authorization.models.DecisionResourceType + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.recommendation: Optional[Union[str, "_models.AccessRecommendationType"]] = None + self.decision = decision + self.justification = justification + self.reviewed_date_time: Optional[datetime.datetime] = None + self.apply_result: Optional[Union[str, "_models.AccessReviewApplyResult"]] = None + self.applied_date_time: Optional[datetime.datetime] = None + self.insights = insights + self.membership_types = membership_types + self.principal_id_properties_applied_by_principal_id: Optional[str] = None + self.principal_type_properties_applied_by_principal_type: Optional[ + Union[str, "_models.AccessReviewActorIdentityType"] + ] = None + self.principal_name_properties_applied_by_principal_name: Optional[str] = None + self.user_principal_name_properties_applied_by_user_principal_name: Optional[str] = None + self.principal_id_properties_reviewed_by_principal_id: Optional[str] = None + self.principal_type_properties_reviewed_by_principal_type: Optional[ + Union[str, "_models.AccessReviewActorIdentityType"] + ] = None + self.principal_name_properties_reviewed_by_principal_name: Optional[str] = None + self.user_principal_name_properties_reviewed_by_user_principal_name: Optional[str] = None + self.type_properties_resource_type = type_properties_resource_type + self.id_properties_resource_id: Optional[str] = None + self.display_name_properties_resource_display_name: Optional[str] = None + self.type_properties_principal_type: Optional[str] = None + self.id_properties_principal_id: Optional[str] = None + self.display_name_properties_principal_display_name: Optional[str] = None + + +class AccessReviewDecisionIdentity(_serialization.Model): + """Target of the decision. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: + "user" and "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + """ + + _validation = { + "type": {"required": True}, + "id": {"readonly": True}, + "display_name": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + } + + _subtype_map = { + "type": { + "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", + "user": "AccessReviewDecisionUserIdentity", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + self.id: Optional[str] = None + self.display_name: Optional[str] = None + + +class AccessReviewDecisionInsight(_serialization.Model): + """Access Review Decision Insight. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review insight id. + :vartype id: str + :ivar name: The access review insight name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar type_properties_type: The type of insight. "userSignInInsight" + :vartype type_properties_type: str or + ~azure.mgmt.authorization.models.AccessReviewDecisionInsightType + :ivar insight_created_date_time: Date Time when the insight was created. + :vartype insight_created_date_time: any + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "insight_created_date_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "insight_created_date_time": {"key": "properties.insightCreatedDateTime", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.type_properties_type: Optional[str] = None + self.insight_created_date_time: Optional[Any] = None + + +class AccessReviewDecisionInsightProperties(_serialization.Model): + """Details of the Insight. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AccessReviewDecisionUserSignInInsightProperties + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar type: The type of insight. Required. "userSignInInsight" + :vartype type: str or ~azure.mgmt.authorization.models.AccessReviewDecisionInsightType + :ivar insight_created_date_time: Date Time when the insight was created. + :vartype insight_created_date_time: any + """ + + _validation = { + "type": {"required": True}, + "insight_created_date_time": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, + } + + _subtype_map = {"type": {"userSignInInsight": "AccessReviewDecisionUserSignInInsightProperties"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + self.insight_created_date_time: Optional[Any] = None + + +class AccessReviewDecisionListResult(_serialization.Model): + """List of access review decisions. + + :ivar value: Access Review Decision list. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewDecision] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewDecision]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewDecision"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review Decision list. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewDecision] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecisionProperties(_serialization.Model): + """Approval Step. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values + are: "Approve", "Deny", and "NoInfoAvailable". + :vartype recommendation: str or ~azure.mgmt.authorization.models.AccessRecommendationType + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. + Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", + "DontKnow", and "NotNotified". + :vartype decision: str or ~azure.mgmt.authorization.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str + :ivar reviewed_date_time: Date Time when a decision was taken. + :vartype reviewed_date_time: ~datetime.datetime + :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", + "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and + "ApplyNotSupported". + :vartype apply_result: str or ~azure.mgmt.authorization.models.AccessReviewApplyResult + :ivar applied_date_time: The date and time when the review decision was applied. + :vartype applied_date_time: ~datetime.datetime + :ivar insights: This is the collection of insights for this decision item. + :vartype insights: list[~azure.mgmt.authorization.models.AccessReviewDecisionInsight] + :ivar membership_types: Every decision item in an access review represents a principal's + membership to a resource. This property represents details of the membership. Examples of this + detail might be whether the principal has direct access or indirect access. + :vartype membership_types: list[str or + ~azure.mgmt.authorization.models.AccessReviewDecisionPrincipalResourceMembershipType] + :ivar principal_id_applied_by_principal_id: The identity id. + :vartype principal_id_applied_by_principal_id: str + :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. + Known values are: "user" and "servicePrincipal". + :vartype principal_type_applied_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name_applied_by_principal_name: The identity display name. + :vartype principal_name_applied_by_principal_name: str + :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). + :vartype user_principal_name_applied_by_user_principal_name: str + :ivar principal_id_reviewed_by_principal_id: The identity id. + :vartype principal_id_reviewed_by_principal_id: str + :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. + Known values are: "user" and "servicePrincipal". + :vartype principal_type_reviewed_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name_reviewed_by_principal_name: The identity display name. + :vartype principal_name_reviewed_by_principal_name: str + :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). + :vartype user_principal_name_reviewed_by_user_principal_name: str + :ivar type_resource_type: The type of resource. "azureRole" + :vartype type_resource_type: str or ~azure.mgmt.authorization.models.DecisionResourceType + :ivar id_resource_id: The id of resource associated with a decision record. + :vartype id_resource_id: str + :ivar display_name_resource_display_name: The display name of resource associated with a + decision record. + :vartype display_name_resource_display_name: str + :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values + are: "user" and "servicePrincipal". + :vartype type_principal_type: str or ~azure.mgmt.authorization.models.DecisionTargetType + :ivar id_principal_id: The id of principal whose access was reviewed. + :vartype id_principal_id: str + :ivar display_name_principal_display_name: The display name of the user whose access was + reviewed. + :vartype display_name_principal_display_name: str + """ + + _validation = { + "recommendation": {"readonly": True}, + "reviewed_date_time": {"readonly": True}, + "apply_result": {"readonly": True}, + "applied_date_time": {"readonly": True}, + "principal_id_applied_by_principal_id": {"readonly": True}, + "principal_type_applied_by_principal_type": {"readonly": True}, + "principal_name_applied_by_principal_name": {"readonly": True}, + "user_principal_name_applied_by_user_principal_name": {"readonly": True}, + "principal_id_reviewed_by_principal_id": {"readonly": True}, + "principal_type_reviewed_by_principal_type": {"readonly": True}, + "principal_name_reviewed_by_principal_name": {"readonly": True}, + "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, + "id_resource_id": {"readonly": True}, + "display_name_resource_display_name": {"readonly": True}, + "id_principal_id": {"readonly": True}, + "display_name_principal_display_name": {"readonly": True}, + } + + _attribute_map = { + "recommendation": {"key": "recommendation", "type": "str"}, + "decision": {"key": "decision", "type": "str"}, + "justification": {"key": "justification", "type": "str"}, + "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, + "apply_result": {"key": "applyResult", "type": "str"}, + "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, + "insights": {"key": "insights", "type": "[AccessReviewDecisionInsight]"}, + "membership_types": {"key": "principalResourceMembership.membershipTypes", "type": "[str]"}, + "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, + "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, + "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, + "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, + "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, + "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, + "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, + "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, + "type_resource_type": {"key": "resource.type", "type": "str"}, + "id_resource_id": {"key": "resource.id", "type": "str"}, + "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, + "type_principal_type": {"key": "principal.type", "type": "str"}, + "id_principal_id": {"key": "principal.id", "type": "str"}, + "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, + } + + def __init__( + self, + *, + decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, + justification: Optional[str] = None, + insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, + membership_types: Optional[ + List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] + ] = None, + type_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", + "NotReviewed", "DontKnow", and "NotNotified". + :paramtype decision: str or ~azure.mgmt.authorization.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + :keyword insights: This is the collection of insights for this decision item. + :paramtype insights: list[~azure.mgmt.authorization.models.AccessReviewDecisionInsight] + :keyword membership_types: Every decision item in an access review represents a principal's + membership to a resource. This property represents details of the membership. Examples of this + detail might be whether the principal has direct access or indirect access. + :paramtype membership_types: list[str or + ~azure.mgmt.authorization.models.AccessReviewDecisionPrincipalResourceMembershipType] + :keyword type_resource_type: The type of resource. "azureRole" + :paramtype type_resource_type: str or ~azure.mgmt.authorization.models.DecisionResourceType + """ + super().__init__(**kwargs) + self.recommendation: Optional[Union[str, "_models.AccessRecommendationType"]] = None + self.decision = decision + self.justification = justification + self.reviewed_date_time: Optional[datetime.datetime] = None + self.apply_result: Optional[Union[str, "_models.AccessReviewApplyResult"]] = None + self.applied_date_time: Optional[datetime.datetime] = None + self.insights = insights + self.membership_types = membership_types + self.principal_id_applied_by_principal_id: Optional[str] = None + self.principal_type_applied_by_principal_type: Optional[Union[str, "_models.AccessReviewActorIdentityType"]] = ( + None + ) + self.principal_name_applied_by_principal_name: Optional[str] = None + self.user_principal_name_applied_by_user_principal_name: Optional[str] = None + self.principal_id_reviewed_by_principal_id: Optional[str] = None + self.principal_type_reviewed_by_principal_type: Optional[ + Union[str, "_models.AccessReviewActorIdentityType"] + ] = None + self.principal_name_reviewed_by_principal_name: Optional[str] = None + self.user_principal_name_reviewed_by_user_principal_name: Optional[str] = None + self.type_resource_type = type_resource_type + self.id_resource_id: Optional[str] = None + self.display_name_resource_display_name: Optional[str] = None + self.type_principal_type: Optional[str] = None + self.id_principal_id: Optional[str] = None + self.display_name_principal_display_name: Optional[str] = None + + +class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): # pylint: disable=name-too-long + """Service Principal Decision Target. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: + "user" and "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + :ivar app_id: The appId for the service principal entity being reviewed. + :vartype app_id: str + """ + + _validation = { + "type": {"required": True}, + "id": {"readonly": True}, + "display_name": {"readonly": True}, + "app_id": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "app_id": {"key": "appId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "servicePrincipal" + self.app_id: Optional[str] = None + + +class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): + """User Decision Target. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: + "user" and "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + :ivar user_principal_name: The user principal name of the user whose access was reviewed. + :vartype user_principal_name: str + """ + + _validation = { + "type": {"required": True}, + "id": {"readonly": True}, + "display_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "user_principal_name": {"key": "userPrincipalName", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "user" + self.user_principal_name: Optional[str] = None + + +class AccessReviewDecisionUserSignInInsightProperties( + AccessReviewDecisionInsightProperties +): # pylint: disable=name-too-long + """User Decision Target. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar type: The type of insight. Required. "userSignInInsight" + :vartype type: str or ~azure.mgmt.authorization.models.AccessReviewDecisionInsightType + :ivar insight_created_date_time: Date Time when the insight was created. + :vartype insight_created_date_time: any + :ivar last_sign_in_date_time: Date Time when the user signed into the tenant. + :vartype last_sign_in_date_time: any + """ + + _validation = { + "type": {"required": True}, + "insight_created_date_time": {"readonly": True}, + "last_sign_in_date_time": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, + "last_sign_in_date_time": {"key": "lastSignInDateTime", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: str = "userSignInInsight" + self.last_sign_in_date_time: Optional[Any] = None + + +class AccessReviewDefaultSettings(_serialization.Model): + """Access Review Default Settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review default settings id. This is only going to be default. + :vartype id: str + :ivar name: The access review default settings name. This is always going to be Access Review + Default Settings. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Known values are: "Approve", "Deny", and "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: 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. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Known values are: "weekly" and "absoluteMonthly". + :vartype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, + "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, + "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, + "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, + "default_decision": {"key": "properties.defaultDecision", "type": "str"}, + "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, + "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, + "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, + "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, + "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, + "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, + "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, + "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, + } + + def __init__( + self, + *, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_properties_recurrence_pattern_type: Optional[ + Union[str, "_models.AccessReviewRecurrencePatternType"] + ] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Known values are: "Approve", "Deny", and "Recommendation". + :paramtype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: 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. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :paramtype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Known values are: "weekly" and "absoluteMonthly". + :paramtype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_properties_recurrence_range_type = type_properties_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type + self.interval = interval + + +class AccessReviewHistoryDefinition(_serialization.Model): + """Access Review History Definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review history definition id. + :vartype id: str + :ivar name: The access review history definition unique id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar display_name: The display name for the history definition. + :vartype display_name: str + :ivar review_history_period_start_date_time: Date time used when selecting review data, all + reviews included in data start on or after this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_start_date_time: ~datetime.datetime + :ivar review_history_period_end_date_time: Date time used when selecting review data, all + reviews included in data end on or before this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_end_date_time: ~datetime.datetime + :ivar decisions: Collection of review decisions which the history data should be filtered on. + For example if Approve and Deny are supplied the data will only contain review results in which + the decision maker approved or denied a review request. + :vartype decisions: list[str or ~azure.mgmt.authorization.models.AccessReviewResult] + :ivar status: This read-only field specifies the of the requested review history data. This is + either requested, in-progress, done or error. Known values are: "Requested", "InProgress", + "Done", and "Error". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionStatus + :ivar created_date_time: Date time when history definition was created. + :vartype created_date_time: ~datetime.datetime + :ivar scopes: A collection of scopes used when selecting review history data. + :vartype scopes: list[~azure.mgmt.authorization.models.AccessReviewScope] + :ivar instances: Set of access review history instances for this history definition. + :vartype instances: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :ivar type_properties_settings_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_properties_settings_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known + values are: "weekly" and "absoluteMonthly". + :vartype type_properties_settings_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and + "servicePrincipal". + :vartype principal_type: str or ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "review_history_period_start_date_time": {"readonly": True}, + "review_history_period_end_date_time": {"readonly": True}, + "status": {"readonly": True}, + "created_date_time": {"readonly": True}, + "principal_id": {"readonly": True}, + "principal_type": {"readonly": True}, + "principal_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "review_history_period_start_date_time": { + "key": "properties.reviewHistoryPeriodStartDateTime", + "type": "iso-8601", + }, + "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, + "decisions": {"key": "properties.decisions", "type": "[str]"}, + "status": {"key": "properties.status", "type": "str"}, + "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, + "scopes": {"key": "properties.scopes", "type": "[AccessReviewScope]"}, + "instances": {"key": "properties.instances", "type": "[AccessReviewHistoryInstance]"}, + "type_properties_settings_range_type": {"key": "properties.settings.range.type", "type": "str"}, + "number_of_occurrences": {"key": "properties.settings.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "properties.settings.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "properties.settings.range.endDate", "type": "iso-8601"}, + "type_properties_settings_pattern_type": {"key": "properties.settings.pattern.type", "type": "str"}, + "interval": {"key": "properties.settings.pattern.interval", "type": "int"}, + "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, + "principal_type": {"key": "properties.createdBy.principalType", "type": "str"}, + "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, + "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, + scopes: Optional[List["_models.AccessReviewScope"]] = None, + instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, + type_properties_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_properties_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The display name for the history definition. + :paramtype display_name: str + :keyword decisions: Collection of review decisions which the history data should be filtered + on. For example if Approve and Deny are supplied the data will only contain review results in + which the decision maker approved or denied a review request. + :paramtype decisions: list[str or ~azure.mgmt.authorization.models.AccessReviewResult] + :keyword scopes: A collection of scopes used when selecting review history data. + :paramtype scopes: list[~azure.mgmt.authorization.models.AccessReviewScope] + :keyword instances: Set of access review history instances for this history definition. + :paramtype instances: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :keyword type_properties_settings_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :paramtype type_properties_settings_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. + Known values are: "weekly" and "absoluteMonthly". + :paramtype type_properties_settings_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.display_name = display_name + self.review_history_period_start_date_time: Optional[datetime.datetime] = None + self.review_history_period_end_date_time: Optional[datetime.datetime] = None + self.decisions = decisions + self.status: Optional[Union[str, "_models.AccessReviewHistoryDefinitionStatus"]] = None + self.created_date_time: Optional[datetime.datetime] = None + self.scopes = scopes + self.instances = instances + self.type_properties_settings_range_type = type_properties_settings_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_properties_settings_pattern_type = type_properties_settings_pattern_type + self.interval = interval + self.principal_id: Optional[str] = None + self.principal_type: Optional[Union[str, "_models.AccessReviewActorIdentityType"]] = None + self.principal_name: Optional[str] = None + self.user_principal_name: Optional[str] = None + + +class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): # pylint: disable=name-too-long + """List of Access Review History Instances. + + :ivar value: Access Review History Definition's Instance list. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewHistoryInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewHistoryInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review History Definition's Instance list. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewHistoryDefinitionListResult(_serialization.Model): + """List of Access Review History Definitions. + + :ivar value: Access Review History Definition list. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewHistoryDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewHistoryDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review History Definition list. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewHistoryDefinitionProperties(_serialization.Model): + """Access Review History Instances. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: The display name for the history definition. + :vartype display_name: str + :ivar review_history_period_start_date_time: Date time used when selecting review data, all + reviews included in data start on or after this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_start_date_time: ~datetime.datetime + :ivar review_history_period_end_date_time: Date time used when selecting review data, all + reviews included in data end on or before this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_end_date_time: ~datetime.datetime + :ivar decisions: Collection of review decisions which the history data should be filtered on. + For example if Approve and Deny are supplied the data will only contain review results in which + the decision maker approved or denied a review request. + :vartype decisions: list[str or ~azure.mgmt.authorization.models.AccessReviewResult] + :ivar status: This read-only field specifies the of the requested review history data. This is + either requested, in-progress, done or error. Known values are: "Requested", "InProgress", + "Done", and "Error". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionStatus + :ivar created_date_time: Date time when history definition was created. + :vartype created_date_time: ~datetime.datetime + :ivar scopes: A collection of scopes used when selecting review history data. + :vartype scopes: list[~azure.mgmt.authorization.models.AccessReviewScope] + :ivar instances: Set of access review history instances for this history definition. + :vartype instances: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :ivar type_settings_range_type: The recurrence range type. The possible values are: endDate, + noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_settings_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: + "weekly" and "absoluteMonthly". + :vartype type_settings_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and + "servicePrincipal". + :vartype principal_type: str or ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + "review_history_period_start_date_time": {"readonly": True}, + "review_history_period_end_date_time": {"readonly": True}, + "status": {"readonly": True}, + "created_date_time": {"readonly": True}, + "principal_id": {"readonly": True}, + "principal_type": {"readonly": True}, + "principal_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "review_history_period_start_date_time": {"key": "reviewHistoryPeriodStartDateTime", "type": "iso-8601"}, + "review_history_period_end_date_time": {"key": "reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, + "decisions": {"key": "decisions", "type": "[str]"}, + "status": {"key": "status", "type": "str"}, + "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, + "scopes": {"key": "scopes", "type": "[AccessReviewScope]"}, + "instances": {"key": "instances", "type": "[AccessReviewHistoryInstance]"}, + "type_settings_range_type": {"key": "settings.range.type", "type": "str"}, + "number_of_occurrences": {"key": "settings.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "settings.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "settings.range.endDate", "type": "iso-8601"}, + "type_settings_pattern_type": {"key": "settings.pattern.type", "type": "str"}, + "interval": {"key": "settings.pattern.interval", "type": "int"}, + "principal_id": {"key": "createdBy.principalId", "type": "str"}, + "principal_type": {"key": "createdBy.principalType", "type": "str"}, + "principal_name": {"key": "createdBy.principalName", "type": "str"}, + "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, + scopes: Optional[List["_models.AccessReviewScope"]] = None, + instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, + type_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The display name for the history definition. + :paramtype display_name: str + :keyword decisions: Collection of review decisions which the history data should be filtered + on. For example if Approve and Deny are supplied the data will only contain review results in + which the decision maker approved or denied a review request. + :paramtype decisions: list[str or ~azure.mgmt.authorization.models.AccessReviewResult] + :keyword scopes: A collection of scopes used when selecting review history data. + :paramtype scopes: list[~azure.mgmt.authorization.models.AccessReviewScope] + :keyword instances: Set of access review history instances for this history definition. + :paramtype instances: list[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] + :keyword type_settings_range_type: The recurrence range type. The possible values are: endDate, + noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :paramtype type_settings_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values + are: "weekly" and "absoluteMonthly". + :paramtype type_settings_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.display_name = display_name + self.review_history_period_start_date_time: Optional[datetime.datetime] = None + self.review_history_period_end_date_time: Optional[datetime.datetime] = None + self.decisions = decisions + self.status: Optional[Union[str, "_models.AccessReviewHistoryDefinitionStatus"]] = None + self.created_date_time: Optional[datetime.datetime] = None + self.scopes = scopes + self.instances = instances + self.type_settings_range_type = type_settings_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_settings_pattern_type = type_settings_pattern_type + self.interval = interval + self.principal_id: Optional[str] = None + self.principal_type: Optional[Union[str, "_models.AccessReviewActorIdentityType"]] = None + self.principal_name: Optional[str] = None + self.user_principal_name: Optional[str] = None + + +class AccessReviewHistoryInstance(_serialization.Model): + """Access Review History Definition Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review history definition instance id. + :vartype id: str + :ivar name: The access review history definition instance unique id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar review_history_period_start_date_time: Date time used when selecting review data, all + reviews included in data start on or after this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_start_date_time: ~datetime.datetime + :ivar review_history_period_end_date_time: Date time used when selecting review data, all + reviews included in data end on or before this date. For use only with one-time/non-recurring + reports. + :vartype review_history_period_end_date_time: ~datetime.datetime + :ivar display_name: The display name for the parent history definition. + :vartype display_name: str + :ivar status: Status of the requested review history instance data. This is either requested, + in-progress, done or error. The state transitions are as follows - Requested -> InProgress -> + Done -> Expired. Known values are: "Requested", "InProgress", "Done", and "Error". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionStatus + :ivar run_date_time: Date time when the history data report is scheduled to be generated. + :vartype run_date_time: ~datetime.datetime + :ivar fulfilled_date_time: Date time when the history data report is scheduled to be generated. + :vartype fulfilled_date_time: ~datetime.datetime + :ivar download_uri: Uri which can be used to retrieve review history data. To generate this + Uri, generateDownloadUri() must be called for a specific accessReviewHistoryDefinitionInstance. + The link expires after a 24 hour period. Callers can see the expiration date time by looking at + the 'se' parameter in the generated uri. + :vartype download_uri: str + :ivar expiration: Date time when history data report expires and the associated data is + deleted. + :vartype expiration: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "download_uri": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "review_history_period_start_date_time": { + "key": "properties.reviewHistoryPeriodStartDateTime", + "type": "iso-8601", + }, + "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "run_date_time": {"key": "properties.runDateTime", "type": "iso-8601"}, + "fulfilled_date_time": {"key": "properties.fulfilledDateTime", "type": "iso-8601"}, + "download_uri": {"key": "properties.downloadUri", "type": "str"}, + "expiration": {"key": "properties.expiration", "type": "iso-8601"}, + } + + def __init__( + self, + *, + review_history_period_start_date_time: Optional[datetime.datetime] = None, + review_history_period_end_date_time: Optional[datetime.datetime] = None, + display_name: Optional[str] = None, + run_date_time: Optional[datetime.datetime] = None, + fulfilled_date_time: Optional[datetime.datetime] = None, + expiration: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword review_history_period_start_date_time: Date time used when selecting review data, all + reviews included in data start on or after this date. For use only with one-time/non-recurring + reports. + :paramtype review_history_period_start_date_time: ~datetime.datetime + :keyword review_history_period_end_date_time: Date time used when selecting review data, all + reviews included in data end on or before this date. For use only with one-time/non-recurring + reports. + :paramtype review_history_period_end_date_time: ~datetime.datetime + :keyword display_name: The display name for the parent history definition. + :paramtype display_name: str + :keyword run_date_time: Date time when the history data report is scheduled to be generated. + :paramtype run_date_time: ~datetime.datetime + :keyword fulfilled_date_time: Date time when the history data report is scheduled to be + generated. + :paramtype fulfilled_date_time: ~datetime.datetime + :keyword expiration: Date time when history data report expires and the associated data is + deleted. + :paramtype expiration: ~datetime.datetime + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.review_history_period_start_date_time = review_history_period_start_date_time + self.review_history_period_end_date_time = review_history_period_end_date_time + self.display_name = display_name + self.status: Optional[Union[str, "_models.AccessReviewHistoryDefinitionStatus"]] = None + self.run_date_time = run_date_time + self.fulfilled_date_time = fulfilled_date_time + self.download_uri: Optional[str] = None + self.expiration = expiration + + +class AccessReviewInstance(_serialization.Model): + """Access Review Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review instance id. + :vartype id: str + :ivar name: The access review instance name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar status: This read-only field specifies the status of an access review instance. Known + values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewInstanceStatus + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar reviewers_type: 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. Known + values are: "Assigned", "Self", and "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.models.AccessReviewInstanceReviewersType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "reviewers_type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, + "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, + "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, + "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.status: Optional[Union[str, "_models.AccessReviewInstanceStatus"]] = None + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type: Optional[Union[str, "_models.AccessReviewInstanceReviewersType"]] = None + + +class AccessReviewInstanceListResult(_serialization.Model): + """List of Access Review Instances. + + :ivar value: Access Review Instance list. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review Instance list. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewInstanceProperties(_serialization.Model): + """Access Review Instance properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: This read-only field specifies the status of an access review instance. Known + values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewInstanceStatus + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar reviewers_type: 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. Known + values are: "Assigned", "Self", and "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.models.AccessReviewInstanceReviewersType + """ + + _validation = { + "status": {"readonly": True}, + "reviewers_type": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, + "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, + "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, + "reviewers_type": {"key": "reviewersType", "type": "str"}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + """ + super().__init__(**kwargs) + self.status: Optional[Union[str, "_models.AccessReviewInstanceStatus"]] = None + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type: Optional[Union[str, "_models.AccessReviewInstanceReviewersType"]] = None + + +class AccessReviewReviewer(_serialization.Model): + """Descriptor for what needs to be reviewed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str + :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and + "servicePrincipal". + :vartype principal_type: str or ~azure.mgmt.authorization.models.AccessReviewReviewerType + """ + + _validation = { + "principal_type": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "principal_type": {"key": "principalType", "type": "str"}, + } + + def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.principal_type: Optional[Union[str, "_models.AccessReviewReviewerType"]] = None + + +class AccessReviewScheduleDefinition(_serialization.Model): + """Access Review Schedule Definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review schedule definition id. + :vartype id: str + :ivar name: The access review schedule definition unique id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str + :ivar status: This read-only field specifies the status of an accessReview. Known values are: + "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", + "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionStatus + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar reviewers_type: 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. Known + values are: "Assigned", "Self", and "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionReviewersType + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :ivar resource_id: ResourceId in which this review is getting created. + :vartype resource_id: str + :ivar role_definition_id: This is used to indicate the role being reviewed. + :vartype role_definition_id: str + :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal + to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and + "redeemedGuestUser". + :vartype principal_type_properties_scope_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewScopePrincipalType + :ivar assignment_state: The role assignment state eligible/active to review. Known values are: + "eligible" and "active". + :vartype assignment_state: str or + ~azure.mgmt.authorization.models.AccessReviewScopeAssignmentState + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :vartype inactive_duration: ~datetime.timedelta + :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. + :vartype expand_nested_memberships: bool + :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. + :vartype include_inherited_access: bool + :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or + not. + :vartype include_access_below_resource: bool + :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :vartype exclude_resource_id: str + :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :vartype exclude_role_definition_id: str + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Known values are: "Approve", "Deny", and "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: 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. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible + values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, + etc. Known values are: "weekly" and "absoluteMonthly". + :vartype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type_properties_created_by_principal_type: The identity type : + user/servicePrincipal. Known values are: "user" and "servicePrincipal". + :vartype principal_type_properties_created_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "reviewers_type": {"readonly": True}, + "resource_id": {"readonly": True}, + "role_definition_id": {"readonly": True}, + "principal_type_properties_scope_principal_type": {"readonly": True}, + "assignment_state": {"readonly": True}, + "principal_id": {"readonly": True}, + "principal_type_properties_created_by_principal_type": {"readonly": True}, + "principal_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, + "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, + "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, + "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, + "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, + "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, + "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, + "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, + "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, + "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, + "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, + "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, + "include_inherited_access": {"key": "properties.scope.includeInheritedAccess", "type": "bool"}, + "include_access_below_resource": {"key": "properties.scope.includeAccessBelowResource", "type": "bool"}, + "exclude_resource_id": {"key": "properties.scope.excludeResourceId", "type": "str"}, + "exclude_role_definition_id": {"key": "properties.scope.excludeRoleDefinitionId", "type": "str"}, + "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, + "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, + "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, + "justification_required_on_approval": { + "key": "properties.settings.justificationRequiredOnApproval", + "type": "bool", + }, + "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, + "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, + "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, + "recommendation_look_back_duration": { + "key": "properties.settings.recommendationLookBackDuration", + "type": "duration", + }, + "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, + "type_properties_settings_recurrence_range_type": { + "key": "properties.settings.recurrence.range.type", + "type": "str", + }, + "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, + "type_properties_settings_recurrence_pattern_type": { + "key": "properties.settings.recurrence.pattern.type", + "type": "str", + }, + "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, + "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, + "principal_type_properties_created_by_principal_type": { + "key": "properties.createdBy.principalType", + "type": "str", + }, + "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, + "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + display_name: Optional[str] = None, + description_for_admins: Optional[str] = None, + description_for_reviewers: Optional[str] = None, + reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + instances: Optional[List["_models.AccessReviewInstance"]] = None, + inactive_duration: Optional[datetime.timedelta] = None, + expand_nested_memberships: Optional[bool] = None, + include_inherited_access: Optional[bool] = None, + include_access_below_resource: Optional[bool] = None, + exclude_resource_id: Optional[str] = None, + exclude_role_definition_id: Optional[str] = None, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_properties_settings_recurrence_range_type: Optional[ + Union[str, "_models.AccessReviewRecurrenceRangeType"] + ] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_properties_settings_recurrence_pattern_type: Optional[ + Union[str, "_models.AccessReviewRecurrencePatternType"] + ] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or + not. + :paramtype expand_nested_memberships: bool + :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or + not. + :paramtype include_inherited_access: bool + :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships + or not. + :paramtype include_access_below_resource: bool + :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :paramtype exclude_resource_id: str + :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :paramtype exclude_role_definition_id: str + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Known values are: "Approve", "Deny", and "Recommendation". + :paramtype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: 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. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The + possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and + "numbered". + :paramtype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, + monthly, etc. Known values are: "weekly" and "absoluteMonthly". + :paramtype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.display_name = display_name + self.status: Optional[Union[str, "_models.AccessReviewScheduleDefinitionStatus"]] = None + self.description_for_admins = description_for_admins + self.description_for_reviewers = description_for_reviewers + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type: Optional[Union[str, "_models.AccessReviewScheduleDefinitionReviewersType"]] = None + self.instances = instances + self.resource_id: Optional[str] = None + self.role_definition_id: Optional[str] = None + self.principal_type_properties_scope_principal_type: Optional[ + Union[str, "_models.AccessReviewScopePrincipalType"] + ] = None + self.assignment_state: Optional[Union[str, "_models.AccessReviewScopeAssignmentState"]] = None + self.inactive_duration = inactive_duration + self.expand_nested_memberships = expand_nested_memberships + self.include_inherited_access = include_inherited_access + self.include_access_below_resource = include_access_below_resource + self.exclude_resource_id = exclude_resource_id + self.exclude_role_definition_id = exclude_role_definition_id + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type + self.interval = interval + self.principal_id: Optional[str] = None + self.principal_type_properties_created_by_principal_type: Optional[ + Union[str, "_models.AccessReviewActorIdentityType"] + ] = None + self.principal_name: Optional[str] = None + self.user_principal_name: Optional[str] = None + + +class AccessReviewScheduleDefinitionListResult(_serialization.Model): + """List of Access Review Schedule Definitions. + + :ivar value: Access Review Schedule Definition list. + :vartype value: list[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Access Review Schedule Definition list. + :paramtype value: list[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewScheduleDefinitionProperties(_serialization.Model): + """Access Review. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str + :ivar status: This read-only field specifies the status of an accessReview. Known values are: + "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", + "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". + :vartype status: str or ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionStatus + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :ivar reviewers_type: 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. Known + values are: "Assigned", "Self", and "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionReviewersType + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :ivar resource_id: ResourceId in which this review is getting created. + :vartype resource_id: str + :ivar role_definition_id: This is used to indicate the role being reviewed. + :vartype role_definition_id: str + :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. + Known values are: "user", "guestUser", "servicePrincipal", "user,group", and + "redeemedGuestUser". + :vartype principal_type_scope_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewScopePrincipalType + :ivar assignment_state: The role assignment state eligible/active to review. Known values are: + "eligible" and "active". + :vartype assignment_state: str or + ~azure.mgmt.authorization.models.AccessReviewScopeAssignmentState + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :vartype inactive_duration: ~datetime.timedelta + :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. + :vartype expand_nested_memberships: bool + :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. + :vartype include_inherited_access: bool + :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or + not. + :vartype include_access_below_resource: bool + :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :vartype exclude_resource_id: str + :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :vartype exclude_role_definition_id: str + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Known values are: "Approve", "Deny", and "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: 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. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known + values are: "weekly" and "absoluteMonthly". + :vartype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. + Known values are: "user" and "servicePrincipal". + :vartype principal_type_created_by_principal_type: str or + ~azure.mgmt.authorization.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + "status": {"readonly": True}, + "reviewers_type": {"readonly": True}, + "resource_id": {"readonly": True}, + "role_definition_id": {"readonly": True}, + "principal_type_scope_principal_type": {"readonly": True}, + "assignment_state": {"readonly": True}, + "principal_id": {"readonly": True}, + "principal_type_created_by_principal_type": {"readonly": True}, + "principal_name": {"readonly": True}, + "user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "display_name": {"key": "displayName", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, + "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, + "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, + "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, + "reviewers_type": {"key": "reviewersType", "type": "str"}, + "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, + "resource_id": {"key": "scope.resourceId", "type": "str"}, + "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, + "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, + "assignment_state": {"key": "scope.assignmentState", "type": "str"}, + "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, + "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, + "include_inherited_access": {"key": "scope.includeInheritedAccess", "type": "bool"}, + "include_access_below_resource": {"key": "scope.includeAccessBelowResource", "type": "bool"}, + "exclude_resource_id": {"key": "scope.excludeResourceId", "type": "str"}, + "exclude_role_definition_id": {"key": "scope.excludeRoleDefinitionId", "type": "str"}, + "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, + "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, + "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, + "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, + "default_decision": {"key": "settings.defaultDecision", "type": "str"}, + "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, + "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, + "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, + "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, + "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, + "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, + "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, + "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, + "principal_id": {"key": "createdBy.principalId", "type": "str"}, + "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, + "principal_name": {"key": "createdBy.principalName", "type": "str"}, + "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + display_name: Optional[str] = None, + description_for_admins: Optional[str] = None, + description_for_reviewers: Optional[str] = None, + reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, + instances: Optional[List["_models.AccessReviewInstance"]] = None, + inactive_duration: Optional[datetime.timedelta] = None, + expand_nested_memberships: Optional[bool] = None, + include_inherited_access: Optional[bool] = None, + include_access_below_resource: Optional[bool] = None, + exclude_resource_id: Optional[str] = None, + exclude_role_definition_id: Optional[str] = None, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: list[~azure.mgmt.authorization.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: list[~azure.mgmt.authorization.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or + not. + :paramtype expand_nested_memberships: bool + :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or + not. + :paramtype include_inherited_access: bool + :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships + or not. + :paramtype include_access_below_resource: bool + :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :paramtype exclude_resource_id: str + :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :paramtype exclude_role_definition_id: str + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Known values are: "Approve", "Deny", and "Recommendation". + :paramtype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: 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. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :paramtype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Known values are: "weekly" and "absoluteMonthly". + :paramtype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.display_name = display_name + self.status: Optional[Union[str, "_models.AccessReviewScheduleDefinitionStatus"]] = None + self.description_for_admins = description_for_admins + self.description_for_reviewers = description_for_reviewers + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type: Optional[Union[str, "_models.AccessReviewScheduleDefinitionReviewersType"]] = None + self.instances = instances + self.resource_id: Optional[str] = None + self.role_definition_id: Optional[str] = None + self.principal_type_scope_principal_type: Optional[Union[str, "_models.AccessReviewScopePrincipalType"]] = None + self.assignment_state: Optional[Union[str, "_models.AccessReviewScopeAssignmentState"]] = None + self.inactive_duration = inactive_duration + self.expand_nested_memberships = expand_nested_memberships + self.include_inherited_access = include_inherited_access + self.include_access_below_resource = include_access_below_resource + self.exclude_resource_id = exclude_resource_id + self.exclude_role_definition_id = exclude_role_definition_id + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_settings_recurrence_range_type = type_settings_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type + self.interval = interval + self.principal_id: Optional[str] = None + self.principal_type_created_by_principal_type: Optional[Union[str, "_models.AccessReviewActorIdentityType"]] = ( + None + ) + self.principal_name: Optional[str] = None + self.user_principal_name: Optional[str] = None + + +class AccessReviewScheduleSettings(_serialization.Model): + """Settings of an Access Review. + + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Known values are: "Approve", "Deny", and "Recommendation". + :vartype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: 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. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, + noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :vartype type_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values + are: "weekly" and "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + """ + + _attribute_map = { + "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, + "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, + "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, + "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, + "default_decision": {"key": "defaultDecision", "type": "str"}, + "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, + "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, + "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, + "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, + "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, + "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, + "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, + "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, + "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, + "interval": {"key": "recurrence.pattern.interval", "type": "int"}, + } + + def __init__( + self, + *, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Known values are: "Approve", "Deny", and "Recommendation". + :paramtype default_decision: str or ~azure.mgmt.authorization.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: 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. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". + :paramtype type_recurrence_range_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values + are: "weekly" and "absoluteMonthly". + :paramtype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super().__init__(**kwargs) + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_recurrence_range_type = type_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_recurrence_pattern_type = type_recurrence_pattern_type + self.interval = interval + + +class AccessReviewScope(_serialization.Model): + """Descriptor for what needs to be reviewed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_id: ResourceId in which this review is getting created. + :vartype resource_id: str + :ivar role_definition_id: This is used to indicate the role being reviewed. + :vartype role_definition_id: str + :ivar principal_type: The identity type user/servicePrincipal to review. Known values are: + "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". + :vartype principal_type: str or ~azure.mgmt.authorization.models.AccessReviewScopePrincipalType + :ivar assignment_state: The role assignment state eligible/active to review. Known values are: + "eligible" and "active". + :vartype assignment_state: str or + ~azure.mgmt.authorization.models.AccessReviewScopeAssignmentState + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :vartype inactive_duration: ~datetime.timedelta + :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. + :vartype expand_nested_memberships: bool + :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. + :vartype include_inherited_access: bool + :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or + not. + :vartype include_access_below_resource: bool + :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :vartype exclude_resource_id: str + :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :vartype exclude_role_definition_id: str + """ + + _validation = { + "resource_id": {"readonly": True}, + "role_definition_id": {"readonly": True}, + "principal_type": {"readonly": True}, + "assignment_state": {"readonly": True}, + } + + _attribute_map = { + "resource_id": {"key": "resourceId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "principal_type": {"key": "principalType", "type": "str"}, + "assignment_state": {"key": "assignmentState", "type": "str"}, + "inactive_duration": {"key": "inactiveDuration", "type": "duration"}, + "expand_nested_memberships": {"key": "expandNestedMemberships", "type": "bool"}, + "include_inherited_access": {"key": "includeInheritedAccess", "type": "bool"}, + "include_access_below_resource": {"key": "includeAccessBelowResource", "type": "bool"}, + "exclude_resource_id": {"key": "excludeResourceId", "type": "str"}, + "exclude_role_definition_id": {"key": "excludeRoleDefinitionId", "type": "str"}, + } + + def __init__( + self, + *, + inactive_duration: Optional[datetime.timedelta] = None, + expand_nested_memberships: Optional[bool] = None, + include_inherited_access: Optional[bool] = None, + include_access_below_resource: Optional[bool] = None, + exclude_resource_id: Optional[str] = None, + exclude_role_definition_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or + not. + :paramtype expand_nested_memberships: bool + :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or + not. + :paramtype include_inherited_access: bool + :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships + or not. + :paramtype include_access_below_resource: bool + :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. + :paramtype exclude_resource_id: str + :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to + exclude. + :paramtype exclude_role_definition_id: str + """ + super().__init__(**kwargs) + self.resource_id: Optional[str] = None + self.role_definition_id: Optional[str] = None + self.principal_type: Optional[Union[str, "_models.AccessReviewScopePrincipalType"]] = None + self.assignment_state: Optional[Union[str, "_models.AccessReviewScopeAssignmentState"]] = None + self.inactive_duration = inactive_duration + self.expand_nested_memberships = expand_nested_memberships + self.include_inherited_access = include_inherited_access + self.include_access_below_resource = include_access_below_resource + self.exclude_resource_id = exclude_resource_id + self.exclude_role_definition_id = exclude_role_definition_id + + +class Alert(_serialization.Model): + """The alert. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The alert ID. + :vartype id: str + :ivar name: The alert name. + :vartype name: str + :ivar type: The alert type. + :vartype type: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_active: False by default; true if the alert is active. + :vartype is_active: bool + :ivar incident_count: The number of generated incidents of the alert. + :vartype incident_count: int + :ivar last_modified_date_time: The date time when the alert configuration was updated or new + incidents were generated. + :vartype last_modified_date_time: ~datetime.datetime + :ivar last_scanned_date_time: The date time when the alert was last scanned. + :vartype last_scanned_date_time: ~datetime.datetime + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + :ivar alert_incidents: The alert incidents. + :vartype alert_incidents: list[~azure.mgmt.authorization.models.AlertIncident] + :ivar alert_configuration: The alert configuration. + :vartype alert_configuration: ~azure.mgmt.authorization.models.AlertConfiguration + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "scope": {"readonly": True}, + "incident_count": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "last_scanned_date_time": {"readonly": True}, + "alert_definition": {"readonly": True}, + "alert_incidents": {"readonly": True}, + "alert_configuration": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "is_active": {"key": "properties.isActive", "type": "bool"}, + "incident_count": {"key": "properties.incidentCount", "type": "int"}, + "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, + "last_scanned_date_time": {"key": "properties.lastScannedDateTime", "type": "iso-8601"}, + "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, + "alert_incidents": {"key": "properties.alertIncidents", "type": "[AlertIncident]"}, + "alert_configuration": {"key": "properties.alertConfiguration", "type": "AlertConfiguration"}, + } + + def __init__(self, *, is_active: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_active: False by default; true if the alert is active. + :paramtype is_active: bool + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope: Optional[str] = None + self.is_active = is_active + self.incident_count: Optional[int] = None + self.last_modified_date_time: Optional[datetime.datetime] = None + self.last_scanned_date_time: Optional[datetime.datetime] = None + self.alert_definition: Optional["_models.AlertDefinition"] = None + self.alert_incidents: Optional[List["_models.AlertIncident"]] = None + self.alert_configuration: Optional["_models.AlertConfiguration"] = None + + +class AlertConfiguration(_serialization.Model): + """Alert configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The alert configuration ID. + :vartype id: str + :ivar name: The alert configuration name. + :vartype name: str + :ivar type: The alert configuration type. + :vartype type: str + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alert_definition_id": {"key": "properties.alertDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "properties.alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.alert_definition_id: Optional[str] = None + self.scope: Optional[str] = None + self.is_enabled = is_enabled + self.alert_configuration_type: Optional[str] = None + self.alert_definition: Optional["_models.AlertDefinition"] = None + + +class AlertConfigurationListResult(_serialization.Model): + """Alert configuration list operation result. + + :ivar value: Alert configuration list. + :vartype value: list[~azure.mgmt.authorization.models.AlertConfiguration] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AlertConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AlertConfiguration"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Alert configuration list. + :paramtype value: list[~azure.mgmt.authorization.models.AlertConfiguration] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AlertConfigurationProperties(_serialization.Model): + """Alert configuration properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureRolesAssignedOutsidePimAlertConfigurationProperties, + DuplicateRoleCreatedAlertConfigurationProperties, + TooManyOwnersAssignedToResourceAlertConfigurationProperties, + TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. Required. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + """ + + _validation = { + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_configuration_type": {"required": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, + } + + _subtype_map = { + "alert_configuration_type": { + "AzureRolesAssignedOutsidePimAlertConfiguration": "AzureRolesAssignedOutsidePimAlertConfigurationProperties", + "DuplicateRoleCreatedAlertConfiguration": "DuplicateRoleCreatedAlertConfigurationProperties", + "TooManyOwnersAssignedToResourceAlertConfiguration": "TooManyOwnersAssignedToResourceAlertConfigurationProperties", + "TooManyPermanentOwnersAssignedToResourceAlertConfiguration": "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", + } + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.alert_definition_id: Optional[str] = None + self.scope: Optional[str] = None + self.is_enabled = is_enabled + self.alert_configuration_type: Optional[str] = None + self.alert_definition: Optional["_models.AlertDefinition"] = None + + +class AlertDefinition(_serialization.Model): + """Alert definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The alert definition ID. + :vartype id: str + :ivar name: The alert definition name. + :vartype name: str + :ivar type: The alert definition type. + :vartype type: str + :ivar display_name: The alert display name. + :vartype display_name: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar description: The alert description. + :vartype description: str + :ivar severity_level: Severity level of the alert. Known values are: "Low", "Medium", and + "High". + :vartype severity_level: str or ~azure.mgmt.authorization.models.SeverityLevel + :ivar security_impact: Security impact of the alert. + :vartype security_impact: str + :ivar mitigation_steps: The methods to mitigate the alert. + :vartype mitigation_steps: str + :ivar how_to_prevent: The ways to prevent the alert. + :vartype how_to_prevent: str + :ivar is_remediatable: True if the alert can be remediated; false, otherwise. + :vartype is_remediatable: bool + :ivar is_configurable: True if the alert configuration can be configured; false, otherwise. + :vartype is_configurable: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "scope": {"readonly": True}, + "description": {"readonly": True}, + "severity_level": {"readonly": True}, + "security_impact": {"readonly": True}, + "mitigation_steps": {"readonly": True}, + "how_to_prevent": {"readonly": True}, + "is_remediatable": {"readonly": True}, + "is_configurable": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "severity_level": {"key": "properties.severityLevel", "type": "str"}, + "security_impact": {"key": "properties.securityImpact", "type": "str"}, + "mitigation_steps": {"key": "properties.mitigationSteps", "type": "str"}, + "how_to_prevent": {"key": "properties.howToPrevent", "type": "str"}, + "is_remediatable": {"key": "properties.isRemediatable", "type": "bool"}, + "is_configurable": {"key": "properties.isConfigurable", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.display_name: Optional[str] = None + self.scope: Optional[str] = None + self.description: Optional[str] = None + self.severity_level: Optional[Union[str, "_models.SeverityLevel"]] = None + self.security_impact: Optional[str] = None + self.mitigation_steps: Optional[str] = None + self.how_to_prevent: Optional[str] = None + self.is_remediatable: Optional[bool] = None + self.is_configurable: Optional[bool] = None + + +class AlertDefinitionListResult(_serialization.Model): + """Alert definition list operation result. + + :ivar value: Alert definition list. + :vartype value: list[~azure.mgmt.authorization.models.AlertDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AlertDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AlertDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Alert definition list. + :paramtype value: list[~azure.mgmt.authorization.models.AlertDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AlertIncident(_serialization.Model): + """Alert incident. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The alert incident ID. + :vartype id: str + :ivar name: The alert incident name. + :vartype name: str + :ivar type: The alert incident type. + :vartype type: str + :ivar alert_incident_type: The alert incident type. + :vartype alert_incident_type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "alert_incident_type": {"key": "properties.alertIncidentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.alert_incident_type: Optional[str] = None + + +class AlertIncidentListResult(_serialization.Model): + """Alert incident list operation result. + + :ivar value: Alert incident list. + :vartype value: list[~azure.mgmt.authorization.models.AlertIncident] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AlertIncident]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AlertIncident"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Alert incident list. + :paramtype value: list[~azure.mgmt.authorization.models.AlertIncident] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AlertIncidentProperties(_serialization.Model): + """Alert incident properties. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureRolesAssignedOutsidePimAlertIncidentProperties, + DuplicateRoleCreatedAlertIncidentProperties, + TooManyOwnersAssignedToResourceAlertIncidentProperties, + TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties + + All required parameters must be populated in order to send to server. + + :ivar alert_incident_type: The alert incident type. Required. + :vartype alert_incident_type: str + """ + + _validation = { + "alert_incident_type": {"required": True}, + } + + _attribute_map = { + "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, + } + + _subtype_map = { + "alert_incident_type": { + "AzureRolesAssignedOutsidePimAlertIncident": "AzureRolesAssignedOutsidePimAlertIncidentProperties", + "DuplicateRoleCreatedAlertIncident": "DuplicateRoleCreatedAlertIncidentProperties", + "TooManyOwnersAssignedToResourceAlertIncident": "TooManyOwnersAssignedToResourceAlertIncidentProperties", + "TooManyPermanentOwnersAssignedToResourceAlertIncident": "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_incident_type: Optional[str] = None + + +class AlertListResult(_serialization.Model): + """Alert list operation result. + + :ivar value: Alert list. + :vartype value: list[~azure.mgmt.authorization.models.Alert] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Alert]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Alert"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Alert list. + :paramtype value: list[~azure.mgmt.authorization.models.Alert] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AlertOperationResult(_serialization.Model): + """Alert operation result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The id of the alert operation. + :vartype id: str + :ivar status: The status of the alert operation. + :vartype status: str + :ivar status_detail: The status detail of the alert operation. + :vartype status_detail: str + :ivar created_date_time: The created date of the alert operation. + :vartype created_date_time: ~datetime.datetime + :ivar last_action_date_time: The last action date of the alert operation. + :vartype last_action_date_time: ~datetime.datetime + :ivar resource_location: The location of the alert associated with the operation. + :vartype resource_location: str + """ + + _validation = { + "id": {"readonly": True}, + "status": {"readonly": True}, + "status_detail": {"readonly": True}, + "created_date_time": {"readonly": True}, + "last_action_date_time": {"readonly": True}, + "resource_location": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "status_detail": {"key": "statusDetail", "type": "str"}, + "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, + "last_action_date_time": {"key": "lastActionDateTime", "type": "iso-8601"}, + "resource_location": {"key": "resourceLocation", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.status: Optional[str] = None + self.status_detail: Optional[str] = None + self.created_date_time: Optional[datetime.datetime] = None + self.last_action_date_time: Optional[datetime.datetime] = None + self.resource_location: Optional[str] = None + + +class ApprovalSettings(_serialization.Model): + """The approval settings. + + :ivar is_approval_required: Determines whether approval is required or not. + :vartype is_approval_required: bool + :ivar is_approval_required_for_extension: Determines whether approval is required for + assignment extension. + :vartype is_approval_required_for_extension: bool + :ivar is_requestor_justification_required: Determine whether requestor justification is + required. + :vartype is_requestor_justification_required: bool + :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", + and "NoApproval". + :vartype approval_mode: str or ~azure.mgmt.authorization.models.ApprovalMode + :ivar approval_stages: The approval stages of the request. + :vartype approval_stages: list[~azure.mgmt.authorization.models.ApprovalStage] + """ + + _attribute_map = { + "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, + "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, + "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, + "approval_mode": {"key": "approvalMode", "type": "str"}, + "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, + } + + def __init__( + self, + *, + is_approval_required: Optional[bool] = None, + is_approval_required_for_extension: Optional[bool] = None, + is_requestor_justification_required: Optional[bool] = None, + approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, + approval_stages: Optional[List["_models.ApprovalStage"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_approval_required: Determines whether approval is required or not. + :paramtype is_approval_required: bool + :keyword is_approval_required_for_extension: Determines whether approval is required for + assignment extension. + :paramtype is_approval_required_for_extension: bool + :keyword is_requestor_justification_required: Determine whether requestor justification is + required. + :paramtype is_requestor_justification_required: bool + :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", + "Parallel", and "NoApproval". + :paramtype approval_mode: str or ~azure.mgmt.authorization.models.ApprovalMode + :keyword approval_stages: The approval stages of the request. + :paramtype approval_stages: list[~azure.mgmt.authorization.models.ApprovalStage] + """ + super().__init__(**kwargs) + self.is_approval_required = is_approval_required + self.is_approval_required_for_extension = is_approval_required_for_extension + self.is_requestor_justification_required = is_requestor_justification_required + self.approval_mode = approval_mode + self.approval_stages = approval_stages + + +class ApprovalStage(_serialization.Model): + """The approval stage. + + :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed + out. + :vartype approval_stage_time_out_in_days: int + :ivar is_approver_justification_required: Determines whether approver need to provide + justification for his decision. + :vartype is_approver_justification_required: bool + :ivar escalation_time_in_minutes: The time in minutes when the approval request would be + escalated if the primary approver does not approve. + :vartype escalation_time_in_minutes: int + :ivar primary_approvers: The primary approver of the request. + :vartype primary_approvers: list[~azure.mgmt.authorization.models.UserSet] + :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. + :vartype is_escalation_enabled: bool + :ivar escalation_approvers: The escalation approver of the request. + :vartype escalation_approvers: list[~azure.mgmt.authorization.models.UserSet] + """ + + _attribute_map = { + "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, + "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, + "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, + "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, + "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, + "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, + } + + def __init__( + self, + *, + approval_stage_time_out_in_days: Optional[int] = None, + is_approver_justification_required: Optional[bool] = None, + escalation_time_in_minutes: Optional[int] = None, + primary_approvers: Optional[List["_models.UserSet"]] = None, + is_escalation_enabled: Optional[bool] = None, + escalation_approvers: Optional[List["_models.UserSet"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed + out. + :paramtype approval_stage_time_out_in_days: int + :keyword is_approver_justification_required: Determines whether approver need to provide + justification for his decision. + :paramtype is_approver_justification_required: bool + :keyword escalation_time_in_minutes: The time in minutes when the approval request would be + escalated if the primary approver does not approve. + :paramtype escalation_time_in_minutes: int + :keyword primary_approvers: The primary approver of the request. + :paramtype primary_approvers: list[~azure.mgmt.authorization.models.UserSet] + :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. + :paramtype is_escalation_enabled: bool + :keyword escalation_approvers: The escalation approver of the request. + :paramtype escalation_approvers: list[~azure.mgmt.authorization.models.UserSet] + """ + super().__init__(**kwargs) + self.approval_stage_time_out_in_days = approval_stage_time_out_in_days + self.is_approver_justification_required = is_approver_justification_required + self.escalation_time_in_minutes = escalation_time_in_minutes + self.primary_approvers = primary_approvers + self.is_escalation_enabled = is_escalation_enabled + self.escalation_approvers = escalation_approvers + + +class AzureRolesAssignedOutsidePimAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long + """The Azure roles assigned outside PIM alert configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. Required. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + """ + + _validation = { + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_configuration_type": {"required": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.alert_configuration_type: str = "AzureRolesAssignedOutsidePimAlertConfiguration" + + +class AzureRolesAssignedOutsidePimAlertIncidentProperties(AlertIncidentProperties): # pylint: disable=name-too-long + """Azure roles assigned outside PIM alert incident properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_incident_type: The alert incident type. Required. + :vartype alert_incident_type: str + :ivar assignee_display_name: The assignee display name. + :vartype assignee_display_name: str + :ivar assignee_user_principal_name: The assignee user principal name. + :vartype assignee_user_principal_name: str + :ivar assignee_id: The assignee ID. + :vartype assignee_id: str + :ivar role_display_name: The role display name. + :vartype role_display_name: str + :ivar role_template_id: The role template ID. + :vartype role_template_id: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar assignment_activated_date: The date the assignment was activated. + :vartype assignment_activated_date: ~datetime.datetime + :ivar requestor_id: The requestor ID. + :vartype requestor_id: str + :ivar requestor_display_name: The requestor display name. + :vartype requestor_display_name: str + :ivar requestor_user_principal_name: The requestor user principal name. + :vartype requestor_user_principal_name: str + """ + + _validation = { + "alert_incident_type": {"required": True}, + "assignee_display_name": {"readonly": True}, + "assignee_user_principal_name": {"readonly": True}, + "assignee_id": {"readonly": True}, + "role_display_name": {"readonly": True}, + "role_template_id": {"readonly": True}, + "role_definition_id": {"readonly": True}, + "assignment_activated_date": {"readonly": True}, + "requestor_id": {"readonly": True}, + "requestor_display_name": {"readonly": True}, + "requestor_user_principal_name": {"readonly": True}, + } + + _attribute_map = { + "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, + "assignee_display_name": {"key": "assigneeDisplayName", "type": "str"}, + "assignee_user_principal_name": {"key": "assigneeUserPrincipalName", "type": "str"}, + "assignee_id": {"key": "assigneeId", "type": "str"}, + "role_display_name": {"key": "roleDisplayName", "type": "str"}, + "role_template_id": {"key": "roleTemplateId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "assignment_activated_date": {"key": "assignmentActivatedDate", "type": "iso-8601"}, + "requestor_id": {"key": "requestorId", "type": "str"}, + "requestor_display_name": {"key": "requestorDisplayName", "type": "str"}, + "requestor_user_principal_name": {"key": "requestorUserPrincipalName", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_incident_type: str = "AzureRolesAssignedOutsidePimAlertIncident" + self.assignee_display_name: Optional[str] = None + self.assignee_user_principal_name: Optional[str] = None + self.assignee_id: Optional[str] = None + self.role_display_name: Optional[str] = None + self.role_template_id: Optional[str] = None + self.role_definition_id: Optional[str] = None + self.assignment_activated_date: Optional[datetime.datetime] = None + self.requestor_id: Optional[str] = None + self.requestor_display_name: Optional[str] = None + self.requestor_user_principal_name: Optional[str] = None + + +class ClassicAdministrator(_serialization.Model): + """Classic Administrators. + + :ivar id: The ID of the administrator. + :vartype id: str + :ivar name: The name of the administrator. + :vartype name: str + :ivar type: The type of the administrator. + :vartype type: str + :ivar email_address: The email address of the administrator. + :vartype email_address: str + :ivar role: The role of the administrator. + :vartype role: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "email_address": {"key": "properties.emailAddress", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + type: Optional[str] = None, + email_address: Optional[str] = None, + role: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The ID of the administrator. + :paramtype id: str + :keyword name: The name of the administrator. + :paramtype name: str + :keyword type: The type of the administrator. + :paramtype type: str + :keyword email_address: The email address of the administrator. + :paramtype email_address: str + :keyword role: The role of the administrator. + :paramtype role: str + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.email_address = email_address + self.role = role + + +class ClassicAdministratorListResult(_serialization.Model): + """ClassicAdministrator list result information. + + :ivar value: An array of administrators. + :vartype value: list[~azure.mgmt.authorization.models.ClassicAdministrator] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ClassicAdministrator]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ClassicAdministrator"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: An array of administrators. + :paramtype value: list[~azure.mgmt.authorization.models.ClassicAdministrator] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CloudErrorBody(_serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class DenyAssignment(_serialization.Model): + """Deny Assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The deny assignment ID. + :vartype id: str + :ivar name: The deny assignment name. + :vartype name: str + :ivar type: The deny assignment type. + :vartype type: str + :ivar deny_assignment_name: The display name of the deny assignment. + :vartype deny_assignment_name: str + :ivar description: The description of the deny assignment. + :vartype description: str + :ivar permissions: An array of permissions that are denied by the deny assignment. + :vartype permissions: list[~azure.mgmt.authorization.models.DenyAssignmentPermission] + :ivar scope: The deny assignment scope. + :vartype scope: str + :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. + Default value is false. + :vartype do_not_apply_to_child_scopes: bool + :ivar principals: Array of principals to which the deny assignment applies. + :vartype principals: list[~azure.mgmt.authorization.models.Principal] + :ivar exclude_principals: Array of principals to which the deny assignment does not apply. + :vartype exclude_principals: list[~azure.mgmt.authorization.models.Principal] + :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and + cannot be edited or deleted. + :vartype is_system_protected: bool + :ivar condition: The conditions on the deny assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. + :vartype condition_version: str + :ivar created_on: Time it was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: Time it was updated. + :vartype updated_on: ~datetime.datetime + :ivar created_by: Id of the user who created the assignment. + :vartype created_by: str + :ivar updated_by: Id of the user who updated the assignment. + :vartype updated_by: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "created_on": {"readonly": True}, + "updated_on": {"readonly": True}, + "created_by": {"readonly": True}, + "updated_by": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, + "scope": {"key": "properties.scope", "type": "str"}, + "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, + "principals": {"key": "properties.principals", "type": "[Principal]"}, + "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, + "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "updated_by": {"key": "properties.updatedBy", "type": "str"}, + } + + def __init__( + self, + *, + deny_assignment_name: Optional[str] = None, + description: Optional[str] = None, + permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, + scope: Optional[str] = None, + do_not_apply_to_child_scopes: Optional[bool] = None, + principals: Optional[List["_models.Principal"]] = None, + exclude_principals: Optional[List["_models.Principal"]] = None, + is_system_protected: Optional[bool] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword deny_assignment_name: The display name of the deny assignment. + :paramtype deny_assignment_name: str + :keyword description: The description of the deny assignment. + :paramtype description: str + :keyword permissions: An array of permissions that are denied by the deny assignment. + :paramtype permissions: list[~azure.mgmt.authorization.models.DenyAssignmentPermission] + :keyword scope: The deny assignment scope. + :paramtype scope: str + :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child + scopes. Default value is false. + :paramtype do_not_apply_to_child_scopes: bool + :keyword principals: Array of principals to which the deny assignment applies. + :paramtype principals: list[~azure.mgmt.authorization.models.Principal] + :keyword exclude_principals: Array of principals to which the deny assignment does not apply. + :paramtype exclude_principals: list[~azure.mgmt.authorization.models.Principal] + :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and + cannot be edited or deleted. + :paramtype is_system_protected: bool + :keyword condition: The conditions on the deny assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. + :paramtype condition_version: str + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.deny_assignment_name = deny_assignment_name + self.description = description + self.permissions = permissions + self.scope = scope + self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes + self.principals = principals + self.exclude_principals = exclude_principals + self.is_system_protected = is_system_protected + self.condition = condition + self.condition_version = condition_version + self.created_on: Optional[datetime.datetime] = None + self.updated_on: Optional[datetime.datetime] = None + self.created_by: Optional[str] = None + self.updated_by: Optional[str] = None + + +class DenyAssignmentFilter(_serialization.Model): + """Deny Assignments filter. + + :ivar deny_assignment_name: Return deny assignment with specified name. + :vartype deny_assignment_name: str + :ivar principal_id: Return all deny assignments where the specified principal is listed in the + principals list of deny assignments. + :vartype principal_id: str + :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is + listed either in the principals list or exclude principals list of deny assignments. + :vartype gdpr_export_principal_id: str + """ + + _attribute_map = { + "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, + } + + def __init__( + self, + *, + deny_assignment_name: Optional[str] = None, + principal_id: Optional[str] = None, + gdpr_export_principal_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword deny_assignment_name: Return deny assignment with specified name. + :paramtype deny_assignment_name: str + :keyword principal_id: Return all deny assignments where the specified principal is listed in + the principals list of deny assignments. + :paramtype principal_id: str + :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is + listed either in the principals list or exclude principals list of deny assignments. + :paramtype gdpr_export_principal_id: str + """ + super().__init__(**kwargs) + self.deny_assignment_name = deny_assignment_name + self.principal_id = principal_id + self.gdpr_export_principal_id = gdpr_export_principal_id + + +class DenyAssignmentListResult(_serialization.Model): + """Deny assignment list operation result. + + :ivar value: Deny assignment list. + :vartype value: list[~azure.mgmt.authorization.models.DenyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DenyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Deny assignment list. + :paramtype value: list[~azure.mgmt.authorization.models.DenyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DenyAssignmentPermission(_serialization.Model): + """Deny assignment permissions. + + :ivar actions: Actions to which the deny assignment does not grant access. + :vartype actions: list[str] + :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. + :vartype not_actions: list[str] + :ivar data_actions: Data actions to which the deny assignment does not grant access. + :vartype data_actions: list[str] + :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant + access. + :vartype not_data_actions: list[str] + :ivar condition: The conditions on the Deny assignment permission. This limits the resources it + applies to. + :vartype condition: str + :ivar condition_version: Version of the condition. + :vartype condition_version: str + """ + + _attribute_map = { + "actions": {"key": "actions", "type": "[str]"}, + "not_actions": {"key": "notActions", "type": "[str]"}, + "data_actions": {"key": "dataActions", "type": "[str]"}, + "not_data_actions": {"key": "notDataActions", "type": "[str]"}, + "condition": {"key": "condition", "type": "str"}, + "condition_version": {"key": "conditionVersion", "type": "str"}, + } + + def __init__( + self, + *, + actions: Optional[List[str]] = None, + not_actions: Optional[List[str]] = None, + data_actions: Optional[List[str]] = None, + not_data_actions: Optional[List[str]] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword actions: Actions to which the deny assignment does not grant access. + :paramtype actions: list[str] + :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. + :paramtype not_actions: list[str] + :keyword data_actions: Data actions to which the deny assignment does not grant access. + :paramtype data_actions: list[str] + :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant + access. + :paramtype not_data_actions: list[str] + :keyword condition: The conditions on the Deny assignment permission. This limits the resources + it applies to. + :paramtype condition: str + :keyword condition_version: Version of the condition. + :paramtype condition_version: str + """ + super().__init__(**kwargs) + self.actions = actions + self.not_actions = not_actions + self.data_actions = data_actions + self.not_data_actions = not_data_actions + self.condition = condition + self.condition_version = condition_version + + +class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): # pylint: disable=name-too-long + """The duplicate role created alert configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. Required. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + """ + + _validation = { + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_configuration_type": {"required": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, + } + + def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.alert_configuration_type: str = "DuplicateRoleCreatedAlertConfiguration" + + +class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): # pylint: disable=name-too-long + """Duplicate role created alert incident properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_incident_type: The alert incident type. Required. + :vartype alert_incident_type: str + :ivar role_name: The role name. + :vartype role_name: str + :ivar duplicate_roles: The duplicate roles. + :vartype duplicate_roles: str + :ivar reason: The reason for the incident. + :vartype reason: str + """ + + _validation = { + "alert_incident_type": {"required": True}, + "role_name": {"readonly": True}, + "duplicate_roles": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, + "role_name": {"key": "roleName", "type": "str"}, + "duplicate_roles": {"key": "duplicateRoles", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_incident_type: str = "DuplicateRoleCreatedAlertIncident" + self.role_name: Optional[str] = None + self.duplicate_roles: Optional[str] = None + self.reason: Optional[str] = None + + +class EligibleChildResource(_serialization.Model): + """Eligible child resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource scope Id. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + + +class EligibleChildResourcesListResult(_serialization.Model): + """Eligible child resources list operation result. + + :ivar value: Eligible child resource list. + :vartype value: list[~azure.mgmt.authorization.models.EligibleChildResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[EligibleChildResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.EligibleChildResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Eligible child resource list. + :paramtype value: list[~azure.mgmt.authorization.models.EligibleChildResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + self.info: Optional[JSON] = None + + +class ErrorDefinition(_serialization.Model): + """Error description and code explaining why an operation failed. + + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.models.ErrorDefinitionProperties + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDefinitionProperties"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: + """ + :keyword error: Error of the list gateway status. + :paramtype error: ~azure.mgmt.authorization.models.ErrorDefinitionProperties + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorDefinitionProperties(_serialization.Model): + """Error description and code explaining why an operation failed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar message: Description of the error. + :vartype message: str + :ivar code: Error code of list gateway. + :vartype code: str + """ + + _validation = { + "message": {"readonly": True}, + } + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "code": {"key": "code", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ + super().__init__(**kwargs) + self.message: Optional[str] = None + self.code = code + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.authorization.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.authorization.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDetail"]] = None + self.additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ExpandedProperties(_serialization.Model): + """ExpandedProperties. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.models.ExpandedPropertiesScope + :ivar role_definition: Details of role definition. + :vartype role_definition: ~azure.mgmt.authorization.models.ExpandedPropertiesRoleDefinition + :ivar principal: Details of the principal. + :vartype principal: ~azure.mgmt.authorization.models.ExpandedPropertiesPrincipal + """ + + _attribute_map = { + "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, + "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, + "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, + } + + def __init__( + self, + *, + scope: Optional["_models.ExpandedPropertiesScope"] = None, + role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, + principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: Details of the resource scope. + :paramtype scope: ~azure.mgmt.authorization.models.ExpandedPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: ~azure.mgmt.authorization.models.ExpandedPropertiesRoleDefinition + :keyword principal: Details of the principal. + :paramtype principal: ~azure.mgmt.authorization.models.ExpandedPropertiesPrincipal + """ + super().__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.principal = principal + + +class ExpandedPropertiesPrincipal(_serialization.Model): + """Details of the principal. + + :ivar id: Id of the principal. + :vartype id: str + :ivar display_name: Display name of the principal. + :vartype display_name: str + :ivar email: Email id of the principal. + :vartype email: str + :ivar type: Type of the principal. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "email": {"key": "email", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + email: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the principal. + :paramtype id: str + :keyword display_name: Display name of the principal. + :paramtype display_name: str + :keyword email: Email id of the principal. + :paramtype email: str + :keyword type: Type of the principal. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.email = email + self.type = type + + +class ExpandedPropertiesRoleDefinition(_serialization.Model): + """Details of role definition. + + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class ExpandedPropertiesScope(_serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Operation(_serialization.Model): + """The definition of a Microsoft.Authorization operation. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.authorization.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.authorization.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ + super().__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class OperationDisplay(_serialization.Model): + """The display information for a Microsoft.Authorization operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The resource provider name: Microsoft.Authorization. + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation that users can perform. + :vartype operation: str + :ivar description: The description for the operation. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None + + +class OperationListResult(_serialization.Model): + """The result of a request to list Microsoft.Authorization operations. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.authorization.models.Operation] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.authorization.models.Operation] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Permission(_serialization.Model): + """Role definition permissions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] + :ivar condition: The conditions on the role definition. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. + :vartype condition_version: str + """ + + _validation = { + "condition": {"readonly": True}, + "condition_version": {"readonly": True}, + } + + _attribute_map = { + "actions": {"key": "actions", "type": "[str]"}, + "not_actions": {"key": "notActions", "type": "[str]"}, + "data_actions": {"key": "dataActions", "type": "[str]"}, + "not_data_actions": {"key": "notDataActions", "type": "[str]"}, + "condition": {"key": "condition", "type": "str"}, + "condition_version": {"key": "conditionVersion", "type": "str"}, + } + + def __init__( + self, + *, + actions: Optional[List[str]] = None, + not_actions: Optional[List[str]] = None, + data_actions: Optional[List[str]] = None, + not_data_actions: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ + super().__init__(**kwargs) + self.actions = actions + self.not_actions = not_actions + self.data_actions = data_actions + self.not_data_actions = not_data_actions + self.condition: Optional[str] = None + self.condition_version: Optional[str] = None + + +class PermissionGetResult(_serialization.Model): + """Permissions information. + + :ivar value: An array of permissions. + :vartype value: list[~azure.mgmt.authorization.models.Permission] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Permission]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: An array of permissions. + :paramtype value: list[~azure.mgmt.authorization.models.Permission] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PIMOnlyModeSettings(_serialization.Model): + """The PIM Only Mode settings. + + :ivar mode: Determines whether the setting is enabled, disabled or report only. Known values + are: "Disabled", "Enabled", and "ReportOnly". + :vartype mode: str or ~azure.mgmt.authorization.models.PIMOnlyMode + :ivar excludes: The list of excluded entities that the rule does not apply to. + :vartype excludes: list[~azure.mgmt.authorization.models.UsersOrServicePrincipalSet] + :ivar excluded_assignment_types: The list of excluded assignment types allowed. + :vartype excluded_assignment_types: list[str or + ~azure.mgmt.authorization.models.ExcludedPrincipalTypes] + """ + + _attribute_map = { + "mode": {"key": "mode", "type": "str"}, + "excludes": {"key": "excludes", "type": "[UsersOrServicePrincipalSet]"}, + "excluded_assignment_types": {"key": "excludedAssignmentTypes", "type": "[str]"}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "_models.PIMOnlyMode"]] = None, + excludes: Optional[List["_models.UsersOrServicePrincipalSet"]] = None, + excluded_assignment_types: Optional[List[Union[str, "_models.ExcludedPrincipalTypes"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword mode: Determines whether the setting is enabled, disabled or report only. Known values + are: "Disabled", "Enabled", and "ReportOnly". + :paramtype mode: str or ~azure.mgmt.authorization.models.PIMOnlyMode + :keyword excludes: The list of excluded entities that the rule does not apply to. + :paramtype excludes: list[~azure.mgmt.authorization.models.UsersOrServicePrincipalSet] + :keyword excluded_assignment_types: The list of excluded assignment types allowed. + :paramtype excluded_assignment_types: list[str or + ~azure.mgmt.authorization.models.ExcludedPrincipalTypes] + """ + super().__init__(**kwargs) + self.mode = mode + self.excludes = excludes + self.excluded_assignment_types = excluded_assignment_types + + +class PolicyAssignmentProperties(_serialization.Model): + """Expanded info of resource scope, role definition and policy. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesScope + :ivar role_definition: Details of role definition. + :vartype role_definition: + ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesRoleDefinition + :ivar policy: Details of the policy. + :vartype policy: ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesPolicy + """ + + _attribute_map = { + "scope": {"key": "scope", "type": "PolicyAssignmentPropertiesScope"}, + "role_definition": {"key": "roleDefinition", "type": "PolicyAssignmentPropertiesRoleDefinition"}, + "policy": {"key": "policy", "type": "PolicyAssignmentPropertiesPolicy"}, + } + + def __init__( + self, + *, + scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, + role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, + policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: Details of the resource scope. + :paramtype scope: ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: + ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesRoleDefinition + :keyword policy: Details of the policy. + :paramtype policy: ~azure.mgmt.authorization.models.PolicyAssignmentPropertiesPolicy + """ + super().__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.policy = policy + + +class PolicyAssignmentPropertiesPolicy(_serialization.Model): + """Details of the policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Id of the policy. + :vartype id: str + :ivar last_modified_by: The name of the entity last modified it. + :vartype last_modified_by: ~azure.mgmt.authorization.models.Principal + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime + """ + + _validation = { + "last_modified_by": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "Principal"}, + "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + last_modified_date_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the policy. + :paramtype id: str + :keyword last_modified_date_time: The last modified date time. + :paramtype last_modified_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.id = id + self.last_modified_by: Optional["_models.Principal"] = None + self.last_modified_date_time = last_modified_date_time + + +class PolicyAssignmentPropertiesRoleDefinition(_serialization.Model): + """Details of role definition. + + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyAssignmentPropertiesScope(_serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyProperties(_serialization.Model): + """Expanded info of resource scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.models.PolicyPropertiesScope + """ + + _validation = { + "scope": {"readonly": True}, + } + + _attribute_map = { + "scope": {"key": "scope", "type": "PolicyPropertiesScope"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.scope: Optional["_models.PolicyPropertiesScope"] = None + + +class PolicyPropertiesScope(_serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Principal(_serialization.Model): + """The name of the entity last modified it. + + :ivar id: The id of the principal made changes. + :vartype id: str + :ivar display_name: The name of the principal made changes. + :vartype display_name: str + :ivar type: Type of principal such as user , group etc. + :vartype type: str + :ivar email: Email of principal. + :vartype email: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "email": {"key": "email", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + type: Optional[str] = None, + email: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the principal made changes. + :paramtype id: str + :keyword display_name: The name of the principal made changes. + :paramtype display_name: str + :keyword type: Type of principal such as user , group etc. + :paramtype type: str + :keyword email: Email of principal. + :paramtype email: str + """ + super().__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + self.email = email + + +class ProviderOperation(_serialization.Model): + """Operation. + + :ivar name: The operation name. + :vartype name: str + :ivar display_name: The operation display name. + :vartype display_name: str + :ivar description: The operation description. + :vartype description: str + :ivar origin: The operation origin. + :vartype origin: str + :ivar properties: The operation properties. + :vartype properties: JSON + :ivar is_data_action: The dataAction flag to specify the operation type. + :vartype is_data_action: bool + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + origin: Optional[str] = None, + properties: Optional[JSON] = None, + is_data_action: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The operation name. + :paramtype name: str + :keyword display_name: The operation display name. + :paramtype display_name: str + :keyword description: The operation description. + :paramtype description: str + :keyword origin: The operation origin. + :paramtype origin: str + :keyword properties: The operation properties. + :paramtype properties: JSON + :keyword is_data_action: The dataAction flag to specify the operation type. + :paramtype is_data_action: bool + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.description = description + self.origin = origin + self.properties = properties + self.is_data_action = is_data_action + + +class ProviderOperationsMetadata(_serialization.Model): + """Provider Operations metadata. + + :ivar id: The provider id. + :vartype id: str + :ivar name: The provider name. + :vartype name: str + :ivar type: The provider type. + :vartype type: str + :ivar display_name: The provider display name. + :vartype display_name: str + :ivar resource_types: The provider resource types. + :vartype resource_types: list[~azure.mgmt.authorization.models.ResourceType] + :ivar operations: The provider operations. + :vartype operations: list[~azure.mgmt.authorization.models.ProviderOperation] + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, + "operations": {"key": "operations", "type": "[ProviderOperation]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + type: Optional[str] = None, + display_name: Optional[str] = None, + resource_types: Optional[List["_models.ResourceType"]] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The provider id. + :paramtype id: str + :keyword name: The provider name. + :paramtype name: str + :keyword type: The provider type. + :paramtype type: str + :keyword display_name: The provider display name. + :paramtype display_name: str + :keyword resource_types: The provider resource types. + :paramtype resource_types: list[~azure.mgmt.authorization.models.ResourceType] + :keyword operations: The provider operations. + :paramtype operations: list[~azure.mgmt.authorization.models.ProviderOperation] + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.display_name = display_name + self.resource_types = resource_types + self.operations = operations + + +class ProviderOperationsMetadataListResult(_serialization.Model): + """Provider operations metadata list. + + :ivar value: The list of providers. + :vartype value: list[~azure.mgmt.authorization.models.ProviderOperationsMetadata] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ProviderOperationsMetadata"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of providers. + :paramtype value: list[~azure.mgmt.authorization.models.ProviderOperationsMetadata] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RecordAllDecisionsProperties(_serialization.Model): + """Record All Decisions payload. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The id of principal which needs to be approved/denied. + :vartype principal_id: str + :ivar resource_id: The id of resource which needs to be approved/denied. + :vartype resource_id: str + :ivar decision: The decision to make. Approvers can take action of Approve/Deny. Known values + are: "Approve" and "Deny". + :vartype decision: str or ~azure.mgmt.authorization.models.RecordAllDecisionsResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "resource_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "decision": {"key": "decision", "type": "str"}, + "justification": {"key": "justification", "type": "str"}, + } + + def __init__( + self, + *, + decision: Optional[Union[str, "_models.RecordAllDecisionsResult"]] = None, + justification: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword decision: The decision to make. Approvers can take action of Approve/Deny. Known + values are: "Approve" and "Deny". + :paramtype decision: str or ~azure.mgmt.authorization.models.RecordAllDecisionsResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ + super().__init__(**kwargs) + self.principal_id: Optional[str] = None + self.resource_id: Optional[str] = None + self.decision = decision + self.justification = justification + + +class ResourceType(_serialization.Model): + """Resource Type. + + :ivar name: The resource type name. + :vartype name: str + :ivar display_name: The resource type display name. + :vartype display_name: str + :ivar operations: The resource type operations. + :vartype operations: list[~azure.mgmt.authorization.models.ProviderOperation] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "operations": {"key": "operations", "type": "[ProviderOperation]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + operations: Optional[List["_models.ProviderOperation"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The resource type name. + :paramtype name: str + :keyword display_name: The resource type display name. + :paramtype display_name: str + :keyword operations: The resource type operations. + :paramtype operations: list[~azure.mgmt.authorization.models.ProviderOperation] + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.operations = operations + + +class RoleAssignment(_serialization.Model): + """Role Assignments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment ID. + :vartype id: str + :ivar name: The role assignment name. + :vartype name: str + :ivar type: The role assignment type. + :vartype type: str + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar description: Description of role assignment. + :vartype description: str + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: Time it was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: Time it was updated. + :vartype updated_on: ~datetime.datetime + :ivar created_by: Id of the user who created the assignment. + :vartype created_by: str + :ivar updated_by: Id of the user who updated the assignment. + :vartype updated_by: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "scope": {"readonly": True}, + "created_on": {"readonly": True}, + "updated_on": {"readonly": True}, + "created_by": {"readonly": True}, + "updated_by": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "updated_by": {"key": "properties.updatedBy", "type": "str"}, + "delegated_managed_identity_resource_id": { + "key": "properties.delegatedManagedIdentityResourceId", + "type": "str", + }, + } + + def __init__( + self, + *, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + description: Optional[str] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + delegated_managed_identity_resource_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword description: Description of role assignment. + :paramtype description: str + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently the only accepted value is + '2.0'. + :paramtype condition_version: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope: Optional[str] = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.description = description + self.condition = condition + self.condition_version = condition_version + self.created_on: Optional[datetime.datetime] = None + self.updated_on: Optional[datetime.datetime] = None + self.created_by: Optional[str] = None + self.updated_by: Optional[str] = None + self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id + + +class RoleAssignmentCreateParameters(_serialization.Model): + """Role assignment create parameters. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. Required. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. Required. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar description: Description of role assignment. + :vartype description: str + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: Time it was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: Time it was updated. + :vartype updated_on: ~datetime.datetime + :ivar created_by: Id of the user who created the assignment. + :vartype created_by: str + :ivar updated_by: Id of the user who updated the assignment. + :vartype updated_by: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str + """ + + _validation = { + "scope": {"readonly": True}, + "role_definition_id": {"required": True}, + "principal_id": {"required": True}, + "created_on": {"readonly": True}, + "updated_on": {"readonly": True}, + "created_by": {"readonly": True}, + "updated_by": {"readonly": True}, + } + + _attribute_map = { + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "updated_by": {"key": "properties.updatedBy", "type": "str"}, + "delegated_managed_identity_resource_id": { + "key": "properties.delegatedManagedIdentityResourceId", + "type": "str", + }, + } + + def __init__( + self, + *, + role_definition_id: str, + principal_id: str, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + description: Optional[str] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + delegated_managed_identity_resource_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword role_definition_id: The role definition ID. Required. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. Required. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword description: Description of role assignment. + :paramtype description: str + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently the only accepted value is + '2.0'. + :paramtype condition_version: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ + super().__init__(**kwargs) + self.scope: Optional[str] = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.description = description + self.condition = condition + self.condition_version = condition_version + self.created_on: Optional[datetime.datetime] = None + self.updated_on: Optional[datetime.datetime] = None + self.created_by: Optional[str] = None + self.updated_by: Optional[str] = None + self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id + + +class RoleAssignmentFilter(_serialization.Model): + """Role Assignments filter. + + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + } + + def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + + +class RoleAssignmentListResult(_serialization.Model): + """Role assignment list operation result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.models.RoleAssignment] + :ivar next_link: The skipToken to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[RoleAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleAssignment] + """ + super().__init__(**kwargs) + self.value = value + self.next_link: Optional[str] = None + + +class RoleAssignmentSchedule(_serialization.Model): + """Role Assignment schedule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule Id. + :vartype id: str + :ivar name: The role assignment schedule name. + :vartype name: str + :ivar type: The role assignment schedule type. + :vartype type: str + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + create this roleAssignmentSchedule. + :vartype role_assignment_schedule_request_id: str + :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated + this roleAssignmentSchedule. + :vartype linked_role_eligibility_schedule_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: + "Activated" and "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.models.AssignmentType + :ivar member_type: Membership type of the role assignment schedule. Known values are: + "Inherited", "Direct", and "Group". + :vartype member_type: str or ~azure.mgmt.authorization.models.MemberType + :ivar status: The status of the role assignment schedule. Known values are: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar start_date_time: Start DateTime when role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role assignment schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "role_assignment_schedule_request_id": {"key": "properties.roleAssignmentScheduleRequestId", "type": "str"}, + "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, + "assignment_type": {"key": "properties.assignmentType", "type": "str"}, + "member_type": {"key": "properties.memberType", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + role_assignment_schedule_request_id: Optional[str] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, + member_type: Optional[Union[str, "_models.MemberType"]] = None, + status: Optional[Union[str, "_models.Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + updated_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_assignment_schedule_request_id: str + :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to + activated this roleAssignmentSchedule. + :paramtype linked_role_eligibility_schedule_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: + "Activated" and "Assigned". + :paramtype assignment_type: str or ~azure.mgmt.authorization.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Known values are: + "Inherited", "Direct", and "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.models.MemberType + :keyword status: The status of the role assignment schedule. Known values are: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.models.Status + :keyword start_date_time: Start DateTime when role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role assignment schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_assignment_schedule_request_id = role_assignment_schedule_request_id + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.assignment_type = assignment_type + self.member_type = member_type + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.updated_on = updated_on + self.expanded_properties = expanded_properties + + +class RoleAssignmentScheduleFilter(_serialization.Model): + """Role assignment schedule filter. + + :ivar principal_id: Returns role assignment schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role assignment schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleAssignmentScheduleInstance(_serialization.Model): + """Information about current or upcoming role assignment schedule instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule instance ID. + :vartype id: str + :ivar name: The role assignment schedule instance name. + :vartype name: str + :ivar type: The role assignment schedule instance type. + :vartype type: str + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar role_assignment_schedule_id: Id of the master role assignment schedule. + :vartype role_assignment_schedule_id: str + :ivar origin_role_assignment_id: Role Assignment Id in external system. + :vartype origin_role_assignment_id: str + :ivar status: The status of the role assignment schedule instance. Known values are: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar start_date_time: The startDateTime of the role assignment schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role assignment schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :vartype linked_role_eligibility_schedule_id: str + :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to + this roleAssignmentScheduleInstance. + :vartype linked_role_eligibility_schedule_instance_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: + "Activated" and "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.models.AssignmentType + :ivar member_type: Membership type of the role assignment schedule. Known values are: + "Inherited", "Direct", and "Group". + :vartype member_type: str or ~azure.mgmt.authorization.models.MemberType + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "role_assignment_schedule_id": {"key": "properties.roleAssignmentScheduleId", "type": "str"}, + "origin_role_assignment_id": {"key": "properties.originRoleAssignmentId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, + "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, + "linked_role_eligibility_schedule_instance_id": { + "key": "properties.linkedRoleEligibilityScheduleInstanceId", + "type": "str", + }, + "assignment_type": {"key": "properties.assignmentType", "type": "str"}, + "member_type": {"key": "properties.memberType", "type": "str"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + role_assignment_schedule_id: Optional[str] = None, + origin_role_assignment_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + linked_role_eligibility_schedule_instance_id: Optional[str] = None, + assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, + member_type: Optional[Union[str, "_models.MemberType"]] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword role_assignment_schedule_id: Id of the master role assignment schedule. + :paramtype role_assignment_schedule_id: str + :keyword origin_role_assignment_id: Role Assignment Id in external system. + :paramtype origin_role_assignment_id: str + :keyword status: The status of the role assignment schedule instance. Known values are: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.models.Status + :keyword start_date_time: The startDateTime of the role assignment schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role assignment schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :paramtype linked_role_eligibility_schedule_id: str + :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked + to this roleAssignmentScheduleInstance. + :paramtype linked_role_eligibility_schedule_instance_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: + "Activated" and "Assigned". + :paramtype assignment_type: str or ~azure.mgmt.authorization.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Known values are: + "Inherited", "Direct", and "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.models.MemberType + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_assignment_schedule_id = role_assignment_schedule_id + self.origin_role_assignment_id = origin_role_assignment_id + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id + self.assignment_type = assignment_type + self.member_type = member_type + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.expanded_properties = expanded_properties + + +class RoleAssignmentScheduleInstanceFilter(_serialization.Model): + """Role assignment schedule instance filter. + + :ivar principal_id: Returns role assignment schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule instances of the specific role + definition. + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str + :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + specific role assignment schedule. + :vartype role_assignment_schedule_id: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "role_assignment_schedule_id": {"key": "roleAssignmentScheduleId", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + role_assignment_schedule_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role assignment schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + specific role assignment schedule. + :paramtype role_assignment_schedule_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + self.role_assignment_schedule_id = role_assignment_schedule_id + + +class RoleAssignmentScheduleInstanceListResult(_serialization.Model): + """Role assignment schedule instance list operation result. + + :ivar value: Role assignment schedule instance list. + :vartype value: list[~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleAssignmentScheduleInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role assignment schedule instance list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleListResult(_serialization.Model): + """Role assignment schedule list operation result. + + :ivar value: Role assignment schedule list. + :vartype value: list[~azure.mgmt.authorization.models.RoleAssignmentSchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleAssignmentSchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleAssignmentSchedule"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role assignment schedule list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleAssignmentSchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequest(_serialization.Model): + """Role Assignment schedule request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule request ID. + :vartype id: str + :ivar name: The role assignment schedule request name. + :vartype name: str + :ivar type: The role assignment schedule request type. + :vartype type: str + :ivar scope: The role assignment schedule request scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", + "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". + :vartype request_type: str or ~azure.mgmt.authorization.models.RequestType + :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar approval_id: The approvalId of the role assignment schedule request. + :vartype approval_id: str + :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role + assignment schedule id being updated. + :vartype target_role_assignment_schedule_id: str + :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id + being updated. + :vartype target_role_assignment_schedule_instance_id: str + :ivar schedule_info: Schedule info of the role assignment schedule. + :vartype schedule_info: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo + :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + activate an eligibility. + :vartype linked_role_eligibility_schedule_id: str + :ivar justification: Justification for the role assignment. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role assignment. + :vartype ticket_info: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesTicketInfo + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule request was created. + :vartype created_on: ~datetime.datetime + :ivar requestor_id: Id of the user who created this request. + :vartype requestor_id: str + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "scope": {"readonly": True}, + "principal_type": {"readonly": True}, + "status": {"readonly": True}, + "approval_id": {"readonly": True}, + "created_on": {"readonly": True}, + "requestor_id": {"readonly": True}, + "expanded_properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "request_type": {"key": "properties.requestType", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "approval_id": {"key": "properties.approvalId", "type": "str"}, + "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, + "target_role_assignment_schedule_instance_id": { + "key": "properties.targetRoleAssignmentScheduleInstanceId", + "type": "str", + }, + "schedule_info": { + "key": "properties.scheduleInfo", + "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", + }, + "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, + "justification": {"key": "properties.justification", "type": "str"}, + "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "requestor_id": {"key": "properties.requestorId", "type": "str"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + request_type: Optional[Union[str, "_models.RequestType"]] = None, + target_role_assignment_schedule_id: Optional[str] = None, + target_role_assignment_schedule_instance_id: Optional[str] = None, + schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + justification: Optional[str] = None, + ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", + "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". + :paramtype request_type: str or ~azure.mgmt.authorization.models.RequestType + :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the + role assignment schedule id being updated. + :paramtype target_role_assignment_schedule_id: str + :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id + being updated. + :paramtype target_role_assignment_schedule_instance_id: str + :keyword schedule_info: Schedule info of the role assignment schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo + :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + activate an eligibility. + :paramtype linked_role_eligibility_schedule_id: str + :keyword justification: Justification for the role assignment. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role assignment. + :paramtype ticket_info: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesTicketInfo + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope: Optional[str] = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type: Optional[Union[str, "_models.PrincipalType"]] = None + self.request_type = request_type + self.status: Optional[Union[str, "_models.Status"]] = None + self.approval_id: Optional[str] = None + self.target_role_assignment_schedule_id = target_role_assignment_schedule_id + self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id + self.schedule_info = schedule_info + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.justification = justification + self.ticket_info = ticket_info + self.condition = condition + self.condition_version = condition_version + self.created_on: Optional[datetime.datetime] = None + self.requestor_id: Optional[str] = None + self.expanded_properties: Optional["_models.ExpandedProperties"] = None + + +class RoleAssignmentScheduleRequestFilter(_serialization.Model): + """Role assignment schedule request filter. + + :ivar principal_id: Returns role assignment requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role assignment requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role assignment requests of specific status. + :vartype status: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "requestor_id": {"key": "requestorId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + requestor_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role assignment requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role assignment requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role assignment requests of specific status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleAssignmentScheduleRequestListResult(_serialization.Model): + """Role assignment schedule request list operation result. + + :ivar value: Role assignment schedule request list. + :vartype value: list[~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role assignment schedule request list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long + """Schedule info of the role assignment schedule. + + :ivar start_date_time: Start DateTime of the role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role assignment schedule. + :vartype expiration: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + """ + + _attribute_map = { + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_date_time: Start DateTime of the role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role assignment schedule. + :paramtype expiration: + ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + """ + super().__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long + """Expiration of the role assignment schedule. + + :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", + "AfterDateTime", and "NoExpiration". + :vartype type: str or ~azure.mgmt.authorization.models.Type + :ivar end_date_time: End DateTime of the role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role assignment schedule in TimeSpan. + :vartype duration: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.Type"]] = None, + end_date_time: Optional[datetime.datetime] = None, + duration: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of the role assignment schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", and "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.models.Type + :keyword end_date_time: End DateTime of the role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role assignment schedule in TimeSpan. + :paramtype duration: str + """ + super().__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long + """Ticket Info of the role assignment. + + :ivar ticket_number: Ticket number for the role assignment. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role assignment. + :vartype ticket_system: str + """ + + _attribute_map = { + "ticket_number": {"key": "ticketNumber", "type": "str"}, + "ticket_system": {"key": "ticketSystem", "type": "str"}, + } + + def __init__( + self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword ticket_number: Ticket number for the role assignment. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role assignment. + :paramtype ticket_system: str + """ + super().__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleDefinition(_serialization.Model): + """Role definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role definition ID. + :vartype id: str + :ivar name: The role definition name. + :vartype name: str + :ivar type: The role definition type. + :vartype type: str + :ivar role_name: The role name. + :vartype role_name: str + :ivar description: The role definition description. + :vartype description: str + :ivar role_type: The role type. + :vartype role_type: str + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.authorization.models.Permission] + :ivar assignable_scopes: Role definition assignable scopes. + :vartype assignable_scopes: list[str] + :ivar created_on: Time it was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: Time it was updated. + :vartype updated_on: ~datetime.datetime + :ivar created_by: Id of the user who created the assignment. + :vartype created_by: str + :ivar updated_by: Id of the user who updated the assignment. + :vartype updated_by: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "created_on": {"readonly": True}, + "updated_on": {"readonly": True}, + "created_by": {"readonly": True}, + "updated_by": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "role_name": {"key": "properties.roleName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "role_type": {"key": "properties.type", "type": "str"}, + "permissions": {"key": "properties.permissions", "type": "[Permission]"}, + "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "updated_by": {"key": "properties.updatedBy", "type": "str"}, + } + + def __init__( + self, + *, + role_name: Optional[str] = None, + description: Optional[str] = None, + role_type: Optional[str] = None, + permissions: Optional[List["_models.Permission"]] = None, + assignable_scopes: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword role_name: The role name. + :paramtype role_name: str + :keyword description: The role definition description. + :paramtype description: str + :keyword role_type: The role type. + :paramtype role_type: str + :keyword permissions: Role definition permissions. + :paramtype permissions: list[~azure.mgmt.authorization.models.Permission] + :keyword assignable_scopes: Role definition assignable scopes. + :paramtype assignable_scopes: list[str] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.role_name = role_name + self.description = description + self.role_type = role_type + self.permissions = permissions + self.assignable_scopes = assignable_scopes + self.created_on: Optional[datetime.datetime] = None + self.updated_on: Optional[datetime.datetime] = None + self.created_by: Optional[str] = None + self.updated_by: Optional[str] = None + + +class RoleDefinitionFilter(_serialization.Model): + """Role Definitions filter. + + :ivar role_name: Returns role definition with the specific name. + :vartype role_name: str + :ivar type: Returns role definition with the specific type. + :vartype type: str + """ + + _attribute_map = { + "role_name": {"key": "roleName", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword role_name: Returns role definition with the specific name. + :paramtype role_name: str + :keyword type: Returns role definition with the specific type. + :paramtype type: str + """ + super().__init__(**kwargs) + self.role_name = role_name + self.type = type + + +class RoleDefinitionListResult(_serialization.Model): + """Role definition list operation result. + + :ivar value: Role definition list. + :vartype value: list[~azure.mgmt.authorization.models.RoleDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Role definition list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilitySchedule(_serialization.Model): + """Role eligibility schedule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule Id. + :vartype id: str + :ivar name: The role eligibility schedule name. + :vartype name: str + :ivar type: The role eligibility schedule type. + :vartype type: str + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + create this roleAssignmentSchedule. + :vartype role_eligibility_schedule_request_id: str + :ivar member_type: Membership type of the role eligibility schedule. Known values are: + "Inherited", "Direct", and "Group". + :vartype member_type: str or ~azure.mgmt.authorization.models.MemberType + :ivar status: The status of the role eligibility schedule. Known values are: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar start_date_time: Start DateTime when role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role eligibility schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "role_eligibility_schedule_request_id": {"key": "properties.roleEligibilityScheduleRequestId", "type": "str"}, + "member_type": {"key": "properties.memberType", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + role_eligibility_schedule_request_id: Optional[str] = None, + member_type: Optional[Union[str, "_models.MemberType"]] = None, + status: Optional[Union[str, "_models.Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + updated_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_eligibility_schedule_request_id: str + :keyword member_type: Membership type of the role eligibility schedule. Known values are: + "Inherited", "Direct", and "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.models.MemberType + :keyword status: The status of the role eligibility schedule. Known values are: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.models.Status + :keyword start_date_time: Start DateTime when role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role eligibility schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id + self.member_type = member_type + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.updated_on = updated_on + self.expanded_properties = expanded_properties + + +class RoleEligibilityScheduleFilter(_serialization.Model): + """Role eligibility schedule filter. + + :ivar principal_id: Returns role eligibility schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule of the specific status. + :vartype status: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role eligibility schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule of the specific status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleEligibilityScheduleInstance(_serialization.Model): + """Information about current or upcoming role eligibility schedule instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule instance ID. + :vartype id: str + :ivar name: The role eligibility schedule instance name. + :vartype name: str + :ivar type: The role eligibility schedule instance type. + :vartype type: str + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. + :vartype role_eligibility_schedule_id: str + :ivar status: The status of the role eligibility schedule instance. Known values are: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar start_date_time: The startDateTime of the role eligibility schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role eligibility schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar member_type: Membership type of the role eligibility schedule. Known values are: + "Inherited", "Direct", and "Group". + :vartype member_type: str or ~azure.mgmt.authorization.models.MemberType + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "role_eligibility_schedule_id": {"key": "properties.roleEligibilityScheduleId", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, + "member_type": {"key": "properties.memberType", "type": "str"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, + role_eligibility_schedule_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + member_type: Optional[Union[str, "_models.MemberType"]] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["_models.ExpandedProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + :keyword status: The status of the role eligibility schedule instance. Known values are: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.models.Status + :keyword start_date_time: The startDateTime of the role eligibility schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role eligibility schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword member_type: Membership type of the role eligibility schedule. Known values are: + "Inherited", "Direct", and "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.models.MemberType + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_eligibility_schedule_id = role_eligibility_schedule_id + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.member_type = member_type + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.expanded_properties = expanded_properties + + +class RoleEligibilityScheduleInstanceFilter(_serialization.Model): + """Role eligibility schedule instance filter. + + :ivar principal_id: Returns role eligibility schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule instances of the specific role + definition. + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule instances of the specific status. + :vartype status: str + :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a + specific role eligibility schedule. + :vartype role_eligibility_schedule_id: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "role_eligibility_schedule_id": {"key": "roleEligibilityScheduleId", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + role_eligibility_schedule_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role eligibility schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule instances of the specific status. + :paramtype status: str + :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to + a specific role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + self.role_eligibility_schedule_id = role_eligibility_schedule_id + + +class RoleEligibilityScheduleInstanceListResult(_serialization.Model): # pylint: disable=name-too-long + """Role eligibility schedule instance list operation result. + + :ivar value: Role eligibility schedule instance list. + :vartype value: list[~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleEligibilityScheduleInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role eligibility schedule instance list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleListResult(_serialization.Model): + """role eligibility schedule list operation result. + + :ivar value: role eligibility schedule list. + :vartype value: list[~azure.mgmt.authorization.models.RoleEligibilitySchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleEligibilitySchedule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleEligibilitySchedule"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: role eligibility schedule list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleEligibilitySchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequest(_serialization.Model): + """Role Eligibility schedule request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule request ID. + :vartype id: str + :ivar name: The role eligibility schedule request name. + :vartype name: str + :ivar type: The role eligibility schedule request type. + :vartype type: str + :ivar scope: The role eligibility schedule request scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Known values are: + "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.models.PrincipalType + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", + "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". + :vartype request_type: str or ~azure.mgmt.authorization.models.RequestType + :ivar status: The status of the role eligibility schedule request. Known values are: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", and "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.models.Status + :ivar approval_id: The approvalId of the role eligibility schedule request. + :vartype approval_id: str + :ivar schedule_info: Schedule info of the role eligibility schedule. + :vartype schedule_info: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo + :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + role eligibility schedule id being updated. + :vartype target_role_eligibility_schedule_id: str + :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id + being updated. + :vartype target_role_eligibility_schedule_instance_id: str + :ivar justification: Justification for the role eligibility. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role eligibility. + :vartype ticket_info: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesTicketInfo + :ivar 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'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule request was created. + :vartype created_on: ~datetime.datetime + :ivar requestor_id: Id of the user who created this request. + :vartype requestor_id: str + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.models.ExpandedProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "scope": {"readonly": True}, + "principal_type": {"readonly": True}, + "status": {"readonly": True}, + "approval_id": {"readonly": True}, + "created_on": {"readonly": True}, + "requestor_id": {"readonly": True}, + "expanded_properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "request_type": {"key": "properties.requestType", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "approval_id": {"key": "properties.approvalId", "type": "str"}, + "schedule_info": { + "key": "properties.scheduleInfo", + "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", + }, + "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, + "target_role_eligibility_schedule_instance_id": { + "key": "properties.targetRoleEligibilityScheduleInstanceId", + "type": "str", + }, + "justification": {"key": "properties.justification", "type": "str"}, + "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, + "condition": {"key": "properties.condition", "type": "str"}, + "condition_version": {"key": "properties.conditionVersion", "type": "str"}, + "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, + "requestor_id": {"key": "properties.requestorId", "type": "str"}, + "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, + } + + def __init__( + self, + *, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + request_type: Optional[Union[str, "_models.RequestType"]] = None, + schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, + target_role_eligibility_schedule_id: Optional[str] = None, + target_role_eligibility_schedule_instance_id: Optional[str] = None, + justification: Optional[str] = None, + ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", + "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". + :paramtype request_type: str or ~azure.mgmt.authorization.models.RequestType + :keyword schedule_info: Schedule info of the role eligibility schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo + :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + role eligibility schedule id being updated. + :paramtype target_role_eligibility_schedule_id: str + :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance + id being updated. + :paramtype target_role_eligibility_schedule_instance_id: str + :keyword justification: Justification for the role eligibility. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role eligibility. + :paramtype ticket_info: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesTicketInfo + :keyword 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'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope: Optional[str] = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type: Optional[Union[str, "_models.PrincipalType"]] = None + self.request_type = request_type + self.status: Optional[Union[str, "_models.Status"]] = None + self.approval_id: Optional[str] = None + self.schedule_info = schedule_info + self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id + self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id + self.justification = justification + self.ticket_info = ticket_info + self.condition = condition + self.condition_version = condition_version + self.created_on: Optional[datetime.datetime] = None + self.requestor_id: Optional[str] = None + self.expanded_properties: Optional["_models.ExpandedProperties"] = None + + +class RoleEligibilityScheduleRequestFilter(_serialization.Model): + """Role eligibility schedule request filter. + + :ivar principal_id: Returns role eligibility requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role eligibility requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role eligibility requests of specific status. + :vartype status: str + """ + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, + "requestor_id": {"key": "requestorId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + requestor_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword principal_id: Returns role eligibility requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role eligibility requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role eligibility requests of specific status. + :paramtype status: str + """ + super().__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleEligibilityScheduleRequestListResult(_serialization.Model): + """Role eligibility schedule request list operation result. + + :ivar value: Role eligibility schedule request list. + :vartype value: list[~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role eligibility schedule request list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): # pylint: disable=name-too-long + """Schedule info of the role eligibility schedule. + + :ivar start_date_time: Start DateTime of the role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role eligibility schedule. + :vartype expiration: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + """ + + _attribute_map = { + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword start_date_time: Start DateTime of the role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role eligibility schedule. + :paramtype expiration: + ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + """ + super().__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration( + _serialization.Model +): # pylint: disable=name-too-long + """Expiration of the role eligibility schedule. + + :ivar type: Type of the role eligibility schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", and "NoExpiration". + :vartype type: str or ~azure.mgmt.authorization.models.Type + :ivar end_date_time: End DateTime of the role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role eligibility schedule in TimeSpan. + :vartype duration: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, + "duration": {"key": "duration", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.Type"]] = None, + end_date_time: Optional[datetime.datetime] = None, + duration: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of the role eligibility schedule expiration. Known values are: + "AfterDuration", "AfterDateTime", and "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.models.Type + :keyword end_date_time: End DateTime of the role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role eligibility schedule in TimeSpan. + :paramtype duration: str + """ + super().__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): # pylint: disable=name-too-long + """Ticket Info of the role eligibility. + + :ivar ticket_number: Ticket number for the role eligibility. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role eligibility. + :vartype ticket_system: str + """ + + _attribute_map = { + "ticket_number": {"key": "ticketNumber", "type": "str"}, + "ticket_system": {"key": "ticketSystem", "type": "str"}, + } + + def __init__( + self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword ticket_number: Ticket number for the role eligibility. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role eligibility. + :paramtype ticket_system: str + """ + super().__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleManagementPolicy(_serialization.Model): + """Role management policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role management policy Id. + :vartype id: str + :ivar name: The role management policy name. + :vartype name: str + :ivar type: The role management policy type. + :vartype type: str + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar display_name: The role management policy display name. + :vartype display_name: str + :ivar description: The role management policy description. + :vartype description: str + :ivar is_organization_default: The role management policy is default policy. + :vartype is_organization_default: bool + :ivar last_modified_by: The name of the entity last modified it. + :vartype last_modified_by: ~azure.mgmt.authorization.models.Principal + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime + :ivar rules: The rule applied to the policy. + :vartype rules: list[~azure.mgmt.authorization.models.RoleManagementPolicyRule] + :ivar effective_rules: The readonly computed rule applied to the policy. + :vartype effective_rules: list[~azure.mgmt.authorization.models.RoleManagementPolicyRule] + :ivar policy_properties: Additional properties of scope. + :vartype policy_properties: ~azure.mgmt.authorization.models.PolicyProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_by": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "effective_rules": {"readonly": True}, + "policy_properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "is_organization_default": {"key": "properties.isOrganizationDefault", "type": "bool"}, + "last_modified_by": {"key": "properties.lastModifiedBy", "type": "Principal"}, + "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, + "rules": {"key": "properties.rules", "type": "[RoleManagementPolicyRule]"}, + "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, + "policy_properties": {"key": "properties.policyProperties", "type": "PolicyProperties"}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + is_organization_default: Optional[bool] = None, + rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword display_name: The role management policy display name. + :paramtype display_name: str + :keyword description: The role management policy description. + :paramtype description: str + :keyword is_organization_default: The role management policy is default policy. + :paramtype is_organization_default: bool + :keyword rules: The rule applied to the policy. + :paramtype rules: list[~azure.mgmt.authorization.models.RoleManagementPolicyRule] + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.display_name = display_name + self.description = description + self.is_organization_default = is_organization_default + self.last_modified_by: Optional["_models.Principal"] = None + self.last_modified_date_time: Optional[datetime.datetime] = None + self.rules = rules + self.effective_rules: Optional[List["_models.RoleManagementPolicyRule"]] = None + self.policy_properties: Optional["_models.PolicyProperties"] = None + + +class RoleManagementPolicyRule(_serialization.Model): + """The role management policy rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, + RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, + RoleManagementPolicyNotificationRule, RoleManagementPolicyPimOnlyModeRule + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + } + + _subtype_map = { + "rule_type": { + "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", + "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", + "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", + "RoleManagementPolicyPimOnlyModeRule": "RoleManagementPolicyPimOnlyModeRule", + } + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + """ + super().__init__(**kwargs) + self.id = id + self.rule_type: Optional[str] = None + self.target = target + + +class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): + """The role management policy approval rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar setting: The approval setting. + :vartype setting: ~azure.mgmt.authorization.models.ApprovalSettings + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "setting": {"key": "setting", "type": "ApprovalSettings"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + setting: Optional["_models.ApprovalSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword setting: The approval setting. + :paramtype setting: ~azure.mgmt.authorization.models.ApprovalSettings + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyApprovalRule" + self.setting = setting + + +class RoleManagementPolicyAssignment(_serialization.Model): + """Role management policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role management policy Id. + :vartype id: str + :ivar name: The role management policy name. + :vartype name: str + :ivar type: The role management policy type. + :vartype type: str + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar role_definition_id: The role definition of management policy assignment. + :vartype role_definition_id: str + :ivar policy_id: The policy id role management policy assignment. + :vartype policy_id: str + :ivar effective_rules: The readonly computed rule applied to the policy. + :vartype effective_rules: list[~azure.mgmt.authorization.models.RoleManagementPolicyRule] + :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. + :vartype policy_assignment_properties: + ~azure.mgmt.authorization.models.PolicyAssignmentProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "effective_rules": {"readonly": True}, + "policy_assignment_properties": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, + "policy_assignment_properties": { + "key": "properties.policyAssignmentProperties", + "type": "PolicyAssignmentProperties", + }, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + policy_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword role_definition_id: The role definition of management policy assignment. + :paramtype role_definition_id: str + :keyword policy_id: The policy id role management policy assignment. + :paramtype policy_id: str + """ + super().__init__(**kwargs) + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.scope = scope + self.role_definition_id = role_definition_id + self.policy_id = policy_id + self.effective_rules: Optional[List["_models.RoleManagementPolicyRule"]] = None + self.policy_assignment_properties: Optional["_models.PolicyAssignmentProperties"] = None + + +class RoleManagementPolicyAssignmentListResult(_serialization.Model): + """Role management policy assignment list operation result. + + :ivar value: Role management policy assignment list. + :vartype value: list[~azure.mgmt.authorization.models.RoleManagementPolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleManagementPolicyAssignment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role management policy assignment list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleManagementPolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): # pylint: disable=name-too-long + """The role management policy authentication context rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar is_enabled: The value indicating if rule is enabled. + :vartype is_enabled: bool + :ivar claim_value: The claim value. + :vartype claim_value: str + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "claim_value": {"key": "claimValue", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + is_enabled: Optional[bool] = None, + claim_value: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword is_enabled: The value indicating if rule is enabled. + :paramtype is_enabled: bool + :keyword claim_value: The claim value. + :paramtype claim_value: str + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" + self.is_enabled = is_enabled + self.claim_value = claim_value + + +class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): + """The role management policy enablement rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar enabled_rules: The list of enabled rules. + :vartype enabled_rules: list[str or ~azure.mgmt.authorization.models.EnablementRules] + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "enabled_rules": {"key": "enabledRules", "type": "[str]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword enabled_rules: The list of enabled rules. + :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.models.EnablementRules] + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyEnablementRule" + self.enabled_rules = enabled_rules + + +class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): + """The role management policy expiration rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar is_expiration_required: The value indicating whether expiration is required. + :vartype is_expiration_required: bool + :ivar maximum_duration: The maximum duration of expiration in timespan. + :vartype maximum_duration: str + :ivar exception_members: The members not restricted by expiration rule. + :vartype exception_members: list[~azure.mgmt.authorization.models.UserSet] + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, + "maximum_duration": {"key": "maximumDuration", "type": "str"}, + "exception_members": {"key": "exceptionMembers", "type": "[UserSet]"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + is_expiration_required: Optional[bool] = None, + maximum_duration: Optional[str] = None, + exception_members: Optional[List["_models.UserSet"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword is_expiration_required: The value indicating whether expiration is required. + :paramtype is_expiration_required: bool + :keyword maximum_duration: The maximum duration of expiration in timespan. + :paramtype maximum_duration: str + :keyword exception_members: The members not restricted by expiration rule. + :paramtype exception_members: list[~azure.mgmt.authorization.models.UserSet] + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyExpirationRule" + self.is_expiration_required = is_expiration_required + self.maximum_duration = maximum_duration + self.exception_members = exception_members + + +class RoleManagementPolicyListResult(_serialization.Model): + """Role management policy list operation result. + + :ivar value: Role management policy list. + :vartype value: list[~azure.mgmt.authorization.models.RoleManagementPolicy] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RoleManagementPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RoleManagementPolicy"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Role management policy list. + :paramtype value: list[~azure.mgmt.authorization.models.RoleManagementPolicy] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): + """The role management policy notification rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar notification_type: The type of notification. "Email" + :vartype notification_type: str or + ~azure.mgmt.authorization.models.NotificationDeliveryMechanism + :ivar notification_level: The notification level. Known values are: "None", "Critical", and + "All". + :vartype notification_level: str or ~azure.mgmt.authorization.models.NotificationLevel + :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and + "Admin". + :vartype recipient_type: str or ~azure.mgmt.authorization.models.RecipientType + :ivar notification_recipients: The list of notification recipients. + :vartype notification_recipients: list[str] + :ivar is_default_recipients_enabled: Determines if the notification will be sent to the + recipient type specified in the policy rule. + :vartype is_default_recipients_enabled: bool + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "notification_type": {"key": "notificationType", "type": "str"}, + "notification_level": {"key": "notificationLevel", "type": "str"}, + "recipient_type": {"key": "recipientType", "type": "str"}, + "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, + "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, + notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, + recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, + notification_recipients: Optional[List[str]] = None, + is_default_recipients_enabled: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword notification_type: The type of notification. "Email" + :paramtype notification_type: str or + ~azure.mgmt.authorization.models.NotificationDeliveryMechanism + :keyword notification_level: The notification level. Known values are: "None", "Critical", and + "All". + :paramtype notification_level: str or ~azure.mgmt.authorization.models.NotificationLevel + :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and + "Admin". + :paramtype recipient_type: str or ~azure.mgmt.authorization.models.RecipientType + :keyword notification_recipients: The list of notification recipients. + :paramtype notification_recipients: list[str] + :keyword is_default_recipients_enabled: Determines if the notification will be sent to the + recipient type specified in the policy rule. + :paramtype is_default_recipients_enabled: bool + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyNotificationRule" + self.notification_type = notification_type + self.notification_level = notification_level + self.recipient_type = recipient_type + self.notification_recipients = notification_recipients + self.is_default_recipients_enabled = is_default_recipients_enabled + + +class RoleManagementPolicyPimOnlyModeRule(RoleManagementPolicyRule): + """The role management policy PIM only mode rule. + + All required parameters must be populated in order to send to server. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: The type of rule. Required. Known values are: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule", and "RoleManagementPolicyPimOnlyModeRule". + :vartype rule_type: str or ~azure.mgmt.authorization.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :ivar pim_only_mode_settings: The PIM Only Mode settings. + :vartype pim_only_mode_settings: ~azure.mgmt.authorization.models.PIMOnlyModeSettings + """ + + _validation = { + "rule_type": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "rule_type": {"key": "ruleType", "type": "str"}, + "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, + "pim_only_mode_settings": {"key": "pimOnlyModeSettings", "type": "PIMOnlyModeSettings"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, + pim_only_mode_settings: Optional["_models.PIMOnlyModeSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.models.RoleManagementPolicyRuleTarget + :keyword pim_only_mode_settings: The PIM Only Mode settings. + :paramtype pim_only_mode_settings: ~azure.mgmt.authorization.models.PIMOnlyModeSettings + """ + super().__init__(id=id, target=target, **kwargs) + self.rule_type: str = "RoleManagementPolicyPimOnlyModeRule" + self.pim_only_mode_settings = pim_only_mode_settings + + +class RoleManagementPolicyRuleTarget(_serialization.Model): + """The role management policy rule target. + + :ivar caller: The caller of the setting. + :vartype caller: str + :ivar operations: The type of operation. + :vartype operations: list[str] + :ivar level: The assignment level to which rule is applied. + :vartype level: str + :ivar target_objects: The list of target objects. + :vartype target_objects: list[str] + :ivar inheritable_settings: The list of inheritable settings. + :vartype inheritable_settings: list[str] + :ivar enforced_settings: The list of enforced settings. + :vartype enforced_settings: list[str] + """ + + _attribute_map = { + "caller": {"key": "caller", "type": "str"}, + "operations": {"key": "operations", "type": "[str]"}, + "level": {"key": "level", "type": "str"}, + "target_objects": {"key": "targetObjects", "type": "[str]"}, + "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, + "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, + } + + def __init__( + self, + *, + caller: Optional[str] = None, + operations: Optional[List[str]] = None, + level: Optional[str] = None, + target_objects: Optional[List[str]] = None, + inheritable_settings: Optional[List[str]] = None, + enforced_settings: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword caller: The caller of the setting. + :paramtype caller: str + :keyword operations: The type of operation. + :paramtype operations: list[str] + :keyword level: The assignment level to which rule is applied. + :paramtype level: str + :keyword target_objects: The list of target objects. + :paramtype target_objects: list[str] + :keyword inheritable_settings: The list of inheritable settings. + :paramtype inheritable_settings: list[str] + :keyword enforced_settings: The list of enforced settings. + :paramtype enforced_settings: list[str] + """ + super().__init__(**kwargs) + self.caller = caller + self.operations = operations + self.level = level + self.target_objects = target_objects + self.inheritable_settings = inheritable_settings + self.enforced_settings = enforced_settings + + +class TooManyOwnersAssignedToResourceAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long + """Too many owners assigned to resource alert configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. Required. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + :ivar threshold_number_of_owners: The threshold number of owners. + :vartype threshold_number_of_owners: int + :ivar threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of + owners out of all role members. + :vartype threshold_percentage_of_owners_out_of_all_role_members: int + """ + + _validation = { + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_configuration_type": {"required": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, + "threshold_number_of_owners": {"key": "thresholdNumberOfOwners", "type": "int"}, + "threshold_percentage_of_owners_out_of_all_role_members": { + "key": "thresholdPercentageOfOwnersOutOfAllRoleMembers", + "type": "int", + }, + } + + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + threshold_number_of_owners: Optional[int] = None, + threshold_percentage_of_owners_out_of_all_role_members: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + :keyword threshold_number_of_owners: The threshold number of owners. + :paramtype threshold_number_of_owners: int + :keyword threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of + owners out of all role members. + :paramtype threshold_percentage_of_owners_out_of_all_role_members: int + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.alert_configuration_type: str = "TooManyOwnersAssignedToResourceAlertConfiguration" + self.threshold_number_of_owners = threshold_number_of_owners + self.threshold_percentage_of_owners_out_of_all_role_members = ( + threshold_percentage_of_owners_out_of_all_role_members + ) + + +class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): # pylint: disable=name-too-long + """Too many owners assigned to resource alert incident properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_incident_type: The alert incident type. Required. + :vartype alert_incident_type: str + :ivar assignee_name: The assignee name. + :vartype assignee_name: str + :ivar assignee_type: The assignee type. + :vartype assignee_type: str + """ + + _validation = { + "alert_incident_type": {"required": True}, + "assignee_name": {"readonly": True}, + "assignee_type": {"readonly": True}, + } + + _attribute_map = { + "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, + "assignee_name": {"key": "assigneeName", "type": "str"}, + "assignee_type": {"key": "assigneeType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_incident_type: str = "TooManyOwnersAssignedToResourceAlertIncident" + self.assignee_name: Optional[str] = None + self.assignee_type: Optional[str] = None + + +class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties( + AlertConfigurationProperties +): # pylint: disable=name-too-long + """Too many permanent owners assigned to resource alert configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_definition_id: The alert definition ID. + :vartype alert_definition_id: str + :ivar scope: The alert scope. + :vartype scope: str + :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :vartype is_enabled: bool + :ivar alert_configuration_type: The alert configuration type. Required. + :vartype alert_configuration_type: str + :ivar alert_definition: The alert definition. + :vartype alert_definition: ~azure.mgmt.authorization.models.AlertDefinition + :ivar threshold_number_of_permanent_owners: The threshold number of permanent owners. + :vartype threshold_number_of_permanent_owners: int + :ivar threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of + permanent owners out of all owners. + :vartype threshold_percentage_of_permanent_owners_out_of_all_owners: int + """ + + _validation = { + "alert_definition_id": {"readonly": True}, + "scope": {"readonly": True}, + "alert_configuration_type": {"required": True}, + "alert_definition": {"readonly": True}, + } + + _attribute_map = { + "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, + "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, + "threshold_number_of_permanent_owners": {"key": "thresholdNumberOfPermanentOwners", "type": "int"}, + "threshold_percentage_of_permanent_owners_out_of_all_owners": { + "key": "thresholdPercentageOfPermanentOwnersOutOfAllOwners", + "type": "int", + }, + } + + def __init__( + self, + *, + is_enabled: Optional[bool] = None, + threshold_number_of_permanent_owners: Optional[int] = None, + threshold_percentage_of_permanent_owners_out_of_all_owners: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the + specific alert. + :paramtype is_enabled: bool + :keyword threshold_number_of_permanent_owners: The threshold number of permanent owners. + :paramtype threshold_number_of_permanent_owners: int + :keyword threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage + of permanent owners out of all owners. + :paramtype threshold_percentage_of_permanent_owners_out_of_all_owners: int + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.alert_configuration_type: str = "TooManyPermanentOwnersAssignedToResourceAlertConfiguration" + self.threshold_number_of_permanent_owners = threshold_number_of_permanent_owners + self.threshold_percentage_of_permanent_owners_out_of_all_owners = ( + threshold_percentage_of_permanent_owners_out_of_all_owners + ) + + +class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties( + AlertIncidentProperties +): # pylint: disable=name-too-long + """Too many permanent owners assigned to resource alert incident properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to server. + + :ivar alert_incident_type: The alert incident type. Required. + :vartype alert_incident_type: str + :ivar assignee_name: The assignee name. + :vartype assignee_name: str + :ivar assignee_type: The assignee type. + :vartype assignee_type: str + """ + + _validation = { + "alert_incident_type": {"required": True}, + "assignee_name": {"readonly": True}, + "assignee_type": {"readonly": True}, + } + + _attribute_map = { + "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, + "assignee_name": {"key": "assigneeName", "type": "str"}, + "assignee_type": {"key": "assigneeType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.alert_incident_type: str = "TooManyPermanentOwnersAssignedToResourceAlertIncident" + self.assignee_name: Optional[str] = None + self.assignee_type: Optional[str] = None + + +class UserSet(_serialization.Model): + """The detail of a user. + + :ivar user_type: The type of user. Known values are: "User", "Group", and "ServicePrincipal". + :vartype user_type: str or ~azure.mgmt.authorization.models.UserType + :ivar is_backup: The value indicating whether the user is a backup fallback approver. + :vartype is_backup: bool + :ivar id: The object id of the user. + :vartype id: str + :ivar description: The description of the user. + :vartype description: str + """ + + _attribute_map = { + "user_type": {"key": "userType", "type": "str"}, + "is_backup": {"key": "isBackup", "type": "bool"}, + "id": {"key": "id", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + user_type: Optional[Union[str, "_models.UserType"]] = None, + is_backup: Optional[bool] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword user_type: The type of user. Known values are: "User", "Group", and + "ServicePrincipal". + :paramtype user_type: str or ~azure.mgmt.authorization.models.UserType + :keyword is_backup: The value indicating whether the user is a backup fallback approver. + :paramtype is_backup: bool + :keyword id: The object id of the user. + :paramtype id: str + :keyword description: The description of the user. + :paramtype description: str + """ + super().__init__(**kwargs) + self.user_type = user_type + self.is_backup = is_backup + self.id = id + self.description = description + + +class UsersOrServicePrincipalSet(_serialization.Model): + """The detail of a subject. + + :ivar type: The type of user. Known values are: "User", "Group", and "ServicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.models.UserType + :ivar id: The object id of the entity. + :vartype id: str + :ivar display_name: The display Name of the entity. + :vartype display_name: str + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.UserType"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + display_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of user. Known values are: "User", "Group", and "ServicePrincipal". + :paramtype type: str or ~azure.mgmt.authorization.models.UserType + :keyword id: The object id of the entity. + :paramtype id: str + :keyword display_name: The display Name of the entity. + :paramtype display_name: str + """ + super().__init__(**kwargs) + self.type = type + self.id = id + self.display_name = display_name + + +class ValidationResponse(_serialization.Model): + """Validation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar is_valid: Whether or not validation succeeded. + :vartype is_valid: bool + :ivar error_info: Failed validation result details. + :vartype error_info: ~azure.mgmt.authorization.models.ValidationResponseErrorInfo + """ + + _validation = { + "is_valid": {"readonly": True}, + } + + _attribute_map = { + "is_valid": {"key": "isValid", "type": "bool"}, + "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, + } + + def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: + """ + :keyword error_info: Failed validation result details. + :paramtype error_info: ~azure.mgmt.authorization.models.ValidationResponseErrorInfo + """ + super().__init__(**kwargs) + self.is_valid: Optional[bool] = None + self.error_info = error_info + + +class ValidationResponseErrorInfo(_serialization.Model): + """Failed validation result details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Error code indicating why validation failed. + :vartype code: str + :ivar message: Message indicating why validation failed. + :vartype message: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code: Optional[str] = None + self.message: Optional[str] = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_patch.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/__init__.py new file mode 100644 index 000000000000..6ea9c98641fb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/__init__.py @@ -0,0 +1,116 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._classic_administrators_operations import ClassicAdministratorsOperations # type: ignore +from ._global_administrator_operations import GlobalAdministratorOperations # type: ignore +from ._deny_assignments_operations import DenyAssignmentsOperations # type: ignore +from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations # type: ignore +from ._role_assignments_operations import RoleAssignmentsOperations # type: ignore +from ._permissions_operations import PermissionsOperations # type: ignore +from ._role_definitions_operations import RoleDefinitionsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations # type: ignore +from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations # type: ignore +from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations # type: ignore +from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations # type: ignore +from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations # type: ignore +from ._access_review_instances_operations import AccessReviewInstancesOperations # type: ignore +from ._access_review_instance_operations import AccessReviewInstanceOperations # type: ignore +from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations # type: ignore +from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations # type: ignore +from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations # type: ignore +from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations # type: ignore +from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations # type: ignore +from ._scope_access_review_history_definition_instance_operations import ScopeAccessReviewHistoryDefinitionInstanceOperations # type: ignore +from ._scope_access_review_history_definition_instances_operations import ScopeAccessReviewHistoryDefinitionInstancesOperations # type: ignore +from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations # type: ignore +from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations # type: ignore +from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations # type: ignore +from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations # type: ignore +from ._scope_access_review_instance_contacted_reviewers_operations import ScopeAccessReviewInstanceContactedReviewersOperations # type: ignore +from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations # type: ignore +from ._access_review_schedule_definitions_assigned_for_my_approval_operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations # type: ignore +from ._access_review_instances_assigned_for_my_approval_operations import AccessReviewInstancesAssignedForMyApprovalOperations # type: ignore +from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations # type: ignore +from ._tenant_level_access_review_instance_contacted_reviewers_operations import TenantLevelAccessReviewInstanceContactedReviewersOperations # type: ignore +from ._eligible_child_resources_operations import EligibleChildResourcesOperations # type: ignore +from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations # type: ignore +from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations # type: ignore +from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations # type: ignore +from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations # type: ignore +from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations # type: ignore +from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations # type: ignore +from ._role_management_policies_operations import RoleManagementPoliciesOperations # type: ignore +from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations # type: ignore +from ._alerts_operations import AlertsOperations # type: ignore +from ._alert_configurations_operations import AlertConfigurationsOperations # type: ignore +from ._alert_definitions_operations import AlertDefinitionsOperations # type: ignore +from ._alert_incidents_operations import AlertIncidentsOperations # type: ignore +from ._alert_operation_operations import AlertOperationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ClassicAdministratorsOperations", + "GlobalAdministratorOperations", + "DenyAssignmentsOperations", + "ProviderOperationsMetadataOperations", + "RoleAssignmentsOperations", + "PermissionsOperations", + "RoleDefinitionsOperations", + "Operations", + "AccessReviewHistoryDefinitionsOperations", + "AccessReviewHistoryDefinitionOperations", + "AccessReviewHistoryDefinitionInstanceOperations", + "AccessReviewHistoryDefinitionInstancesOperations", + "AccessReviewScheduleDefinitionsOperations", + "AccessReviewInstancesOperations", + "AccessReviewInstanceOperations", + "AccessReviewInstanceDecisionsOperations", + "AccessReviewInstanceContactedReviewersOperations", + "AccessReviewDefaultSettingsOperations", + "ScopeAccessReviewHistoryDefinitionsOperations", + "ScopeAccessReviewHistoryDefinitionOperations", + "ScopeAccessReviewHistoryDefinitionInstanceOperations", + "ScopeAccessReviewHistoryDefinitionInstancesOperations", + "ScopeAccessReviewScheduleDefinitionsOperations", + "ScopeAccessReviewInstancesOperations", + "ScopeAccessReviewInstanceOperations", + "ScopeAccessReviewInstanceDecisionsOperations", + "ScopeAccessReviewInstanceContactedReviewersOperations", + "ScopeAccessReviewDefaultSettingsOperations", + "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", + "AccessReviewInstancesAssignedForMyApprovalOperations", + "AccessReviewInstanceMyDecisionsOperations", + "TenantLevelAccessReviewInstanceContactedReviewersOperations", + "EligibleChildResourcesOperations", + "RoleAssignmentSchedulesOperations", + "RoleAssignmentScheduleInstancesOperations", + "RoleAssignmentScheduleRequestsOperations", + "RoleEligibilitySchedulesOperations", + "RoleEligibilityScheduleInstancesOperations", + "RoleEligibilityScheduleRequestsOperations", + "RoleManagementPoliciesOperations", + "RoleManagementPolicyAssignmentsOperations", + "AlertsOperations", + "AlertConfigurationsOperations", + "AlertDefinitionsOperations", + "AlertIncidentsOperations", + "AlertOperationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_default_settings_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_default_settings_operations.py index 635c42dbc02c..e9edfe2fc4ef 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_default_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,12 +46,12 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,12 +74,12 @@ def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,30 +98,30 @@ class AccessReviewDefaultSettingsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,24 +132,20 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +155,12 @@ def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore @overload def put( @@ -177,53 +169,45 @@ def put( """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,9 +218,7 @@ def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) @@ -248,22 +230,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,13 +253,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instance_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instance_operations.py index 431dba43d577..ad730febacec 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +48,14 @@ def build_generate_download_uri_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,25 +66,26 @@ def build_generate_download_uri_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewHistoryDefinitionInstanceOperations: +class AccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def generate_download_uri( @@ -97,12 +99,11 @@ def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -113,26 +114,22 @@ def generate_download_uri( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,13 +139,9 @@ def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instances_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instances_operations.py index e3bc81edcfea..d0a7d37440d9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +47,13 @@ def build_list_request(history_definition_id: str, subscription_id: str, **kwarg _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,48 +64,46 @@ def build_list_request(history_definition_id: str, subscription_id: str, **kwarg return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewHistoryDefinitionInstancesOperations: +class AccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.AccessReviewHistoryInstance"]: + def list(self, history_definition_id: str, **kwargs: Any) -> ItemPaged["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,34 +114,20 @@ def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.A def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -153,11 +137,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,7 +153,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_operations.py index 696f778cdd14..3d53ee589051 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definition_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +48,13 @@ def build_create_request(history_definition_id: str, subscription_id: str, **kwa _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,13 +78,13 @@ def build_delete_by_id_request(history_definition_id: str, subscription_id: str, _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,19 +101,20 @@ class AccessReviewHistoryDefinitionOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def create( @@ -128,33 +130,35 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( - self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + history_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -162,7 +166,7 @@ def create( def create( self, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -170,19 +174,14 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties or + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,9 +192,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) @@ -207,23 +204,21 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,16 +228,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -252,12 +243,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -268,25 +258,21 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,8 +283,4 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definitions_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definitions_operations.py index 031558519eec..d151596cc2b7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_history_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,12 +47,12 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,13 +76,13 @@ def build_get_by_id_request(history_definition_id: str, subscription_id: str, ** _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,44 +99,42 @@ class AccessReviewHistoryDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewHistoryDefinition"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -147,34 +145,20 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -184,11 +168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,22 +185,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions" - } - @distributed_trace def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,25 +206,21 @@ def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.Access _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -255,13 +230,9 @@ def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.Access error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_contacted_reviewers_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_contacted_reviewers_operations.py index f26b7dd35419..27058cbfbe8f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +47,14 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,52 +65,50 @@ def build_list_request(schedule_definition_id: str, id: str, subscription_id: st return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceContactedReviewersOperations: +class AccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewContactedReviewer"]: + ) -> ItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,35 +119,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -159,11 +143,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -175,7 +159,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_decisions_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_decisions_operations.py index fe0a8f1c6f7b..fd52277c8567 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,14 +49,14 @@ def build_list_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,24 +75,25 @@ class AccessReviewInstanceDecisionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: + ) -> ItemPaged["_models.AccessReviewDecision"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -104,22 +105,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,36 +127,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -169,11 +152,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -185,7 +168,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_my_decisions_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_my_decisions_operations.py index 525e2d35e491..7fabc54d280d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_my_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,13 +50,13 @@ def build_list_request( _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,14 +80,14 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: s _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,14 +110,14 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,30 +130,31 @@ def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstanceMyDecisionsOperations: +class AccessReviewInstanceMyDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: + ) -> ItemPaged["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -165,22 +166,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,35 +188,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -229,11 +212,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +229,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - @distributed_trace def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any @@ -262,12 +241,11 @@ def get_by_id( :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,26 +256,22 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +281,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore @overload def patch( @@ -338,14 +308,12 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @@ -355,7 +323,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,13 +337,12 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @@ -385,7 +352,7 @@ def patch( schedule_definition_id: str, id: str, decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], + properties: Union[_models.AccessReviewDecisionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. @@ -397,18 +364,13 @@ def patch( :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewDecisionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewDecisionProperties or IO[bytes] :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision + :rtype: ~azure.mgmt.authorization.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,9 +381,7 @@ def patch( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) @@ -433,7 +393,7 @@ def patch( else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - request = build_patch_request( + _request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, @@ -441,16 +401,14 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +418,9 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) + deserialized = self._deserialize("AccessReviewDecision", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_operations.py similarity index 75% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_operations.py index 6480468e873e..460092e88a8c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,14 +46,14 @@ def build_stop_request(schedule_definition_id: str, id: str, subscription_id: st _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,14 +77,14 @@ def build_reset_decisions_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,14 +108,14 @@ def build_apply_decisions_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,14 +139,14 @@ def build_send_reminders_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,13 +168,13 @@ def build_accept_recommendations_request(schedule_definition_id: str, id: str, * _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,19 +191,20 @@ class AccessReviewInstanceOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -214,12 +216,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,26 +231,22 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -260,11 +257,7 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -276,12 +269,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,26 +284,22 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -322,11 +310,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -338,12 +322,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,26 +337,22 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -384,11 +363,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -400,12 +375,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,26 +390,22 @@ def send_reminders( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,11 +416,7 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def accept_recommendations( # pylint: disable=inconsistent-return-statements @@ -462,12 +428,11 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,25 +443,21 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_accept_recommendations_request( + _request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,8 +468,4 @@ def accept_recommendations( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_assigned_for_my_approval_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_assigned_for_my_approval_operations.py index 490c4997b6fd..2b0336a99eea 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,12 +46,12 @@ def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = N _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,13 +75,13 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,30 +92,31 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewInstancesAssignedForMyApprovalOperations: +class AccessReviewInstancesAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: + ) -> ItemPaged["_models.AccessReviewInstance"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -126,22 +126,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -152,34 +148,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -189,11 +171,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,10 +188,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get single access review instance assigned for my approval. @@ -218,12 +196,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,25 +211,21 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -262,13 +235,9 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_operations.py index 980b5e96f2d8..b4246e01cafb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,13 +50,13 @@ def build_list_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,14 +80,14 @@ def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_i _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,14 +110,14 @@ def build_create_request(schedule_definition_id: str, id: str, subscription_id: _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,24 +136,25 @@ class AccessReviewInstancesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: + ) -> ItemPaged["_models.AccessReviewInstance"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. Required. @@ -163,22 +164,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,35 +186,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -227,11 +210,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,10 +227,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: """Get access review instances. @@ -256,12 +235,11 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -272,26 +250,22 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,16 +275,12 @@ def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload def create( @@ -329,14 +299,12 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -345,7 +313,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,13 +325,12 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -372,7 +339,7 @@ def create( self, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -382,18 +349,13 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewInstanceProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties or IO[bytes] :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,9 +366,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) @@ -418,7 +378,7 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, @@ -426,16 +386,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,13 +403,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 184634f92127..0027a9906184 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,28 +56,29 @@ def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRe return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom @@ -86,22 +86,19 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,33 +109,19 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -148,11 +131,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,5 +147,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_operations.py index 174c294924f2..0aebb02de458 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_access_review_schedule_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,12 +48,12 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,13 +77,13 @@ def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, * _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,13 +105,13 @@ def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,13 +136,13 @@ def build_create_or_update_by_id_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,13 +166,13 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", - ) # pylint: disable=line-too-long + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,28 +183,29 @@ def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwar return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class AccessReviewScheduleDefinitionsOperations: +class AccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom @@ -212,22 +213,19 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,34 +236,20 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -275,11 +259,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,22 +276,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - @distributed_trace def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,25 +297,21 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -346,16 +321,12 @@ def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.Acces error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -365,12 +336,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -381,25 +351,21 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +376,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -430,33 +392,35 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, + schedule_definition_id: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -464,7 +428,7 @@ def create_or_update_by_id( def create_or_update_by_id( self, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -472,19 +436,14 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties or + IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,9 +454,7 @@ def create_or_update_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) @@ -509,23 +466,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +490,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -554,12 +505,11 @@ def stop( # pylint: disable=inconsistent-return-statements :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -570,25 +520,21 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,8 +545,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_configurations_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_configurations_operations.py index 5685979c2f3e..ecf1a561ba22 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_configurations_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +47,13 @@ def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,13 +75,13 @@ def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReques # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +107,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,19 +124,20 @@ class AlertConfigurationsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`alert_configurations` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfiguration: @@ -152,12 +153,11 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur :type scope: str :param alert_id: The name of the alert configuration to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertConfiguration or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration + :rtype: ~azure.mgmt.authorization.models.AlertConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,25 +168,21 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,17 +191,15 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertConfigur map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertConfiguration", pipeline_response) + deserialized = self._deserialize("AlertConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return deserialized # type: ignore @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, scope: str, alert_id: str, @@ -221,19 +215,18 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration + :type parameters: ~azure.mgmt.authorization.models.AlertConfiguration :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + def update( + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert configuration. @@ -242,11 +235,10 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -254,7 +246,7 @@ def update( # pylint: disable=inconsistent-return-statements @distributed_trace def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.AlertConfiguration, IO[bytes]], **kwargs: Any ) -> None: """Update an alert configuration. @@ -263,17 +255,13 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert configuration to update. Required. :type alert_id: str :param parameters: Parameters for the alert configuration. Is either a AlertConfiguration type - or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.AlertConfiguration or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,9 +272,7 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -298,23 +284,21 @@ def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "AlertConfiguration") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,31 +308,25 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertConfiguration"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> ItemPaged["_models.AlertConfiguration"]: """Gets alert configurations for a resource scope. :param scope: The scope of the alert configuration. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertConfiguration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AlertConfiguration] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,33 +337,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertCo def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertConfigurationListResult", pipeline_response) @@ -395,11 +359,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,5 +374,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertConfigurations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_definitions_operations.py similarity index 67% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_definitions_operations.py index c6975619eab0..4b0477247a9d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,13 +46,13 @@ def build_get_request(scope: str, alert_definition_id: str, **kwargs: Any) -> Ht # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertDefinitionId": _SERIALIZER.url("alert_definition_id", alert_definition_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +76,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,19 +93,20 @@ class AlertDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`alert_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.AlertDefinition: @@ -121,12 +122,11 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al :type scope: str :param alert_definition_id: The name of the alert definition to get. Required. :type alert_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition + :rtype: ~azure.mgmt.authorization.models.AlertDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,25 +137,21 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_definition_id=alert_definition_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,38 +160,30 @@ def get(self, scope: str, alert_definition_id: str, **kwargs: Any) -> _models.Al map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertDefinition", pipeline_response) + deserialized = self._deserialize("AlertDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions/{alertDefinitionId}" - } + return deserialized # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDefinition"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> ItemPaged["_models.AlertDefinition"]: """Gets alert definitions for a resource scope. :param scope: The scope of the alert definition. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AlertDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,33 +194,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.AlertDe def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertDefinitionListResult", pipeline_response) @@ -242,11 +216,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,5 +231,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_incidents_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_incidents_operations.py index 3b5931f1527a..a8dbe0a899fb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_incidents_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_incidents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +47,14 @@ def build_get_request(scope: str, alert_id: str, alert_incident_id: str, **kwarg _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,13 +75,13 @@ def build_list_for_scope_request(scope: str, alert_id: str, **kwargs: Any) -> Ht # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,14 +103,14 @@ def build_remediate_request(scope: str, alert_id: str, alert_incident_id: str, * _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), "alertIncidentId": _SERIALIZER.url("alert_incident_id", alert_incident_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,19 +127,20 @@ class AlertIncidentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`alert_incidents` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) -> _models.AlertIncident: @@ -157,12 +158,11 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) :type alert_id: str :param alert_incident_id: The name of the alert incident to get. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertIncident or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident + :rtype: ~azure.mgmt.authorization.models.AlertIncident :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -173,26 +173,22 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertIncident] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,40 +197,32 @@ def get(self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertIncident", pipeline_response) + deserialized = self._deserialize("AlertIncident", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}" - } + return deserialized # type: ignore @distributed_trace - def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable["_models.AlertIncident"]: + def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> ItemPaged["_models.AlertIncident"]: """Gets alert incidents for a resource scope. :param scope: The scope of the alert incident. Required. :type scope: str :param alert_id: The name of the alert. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertIncident or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AlertIncident] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertIncidentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,34 +233,20 @@ def list_for_scope(self, scope: str, alert_id: str, **kwargs: Any) -> Iterable[" def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertIncidentListResult", pipeline_response) @@ -282,11 +256,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -298,10 +272,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents" - } - @distributed_trace def remediate( # pylint: disable=inconsistent-return-statements self, scope: str, alert_id: str, alert_incident_id: str, **kwargs: Any @@ -314,12 +284,11 @@ def remediate( # pylint: disable=inconsistent-return-statements :type alert_id: str :param alert_incident_id: The name of the alert incident to remediate. Required. :type alert_incident_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,26 +299,22 @@ def remediate( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_remediate_request( + _request = build_remediate_request( scope=scope, alert_id=alert_id, alert_incident_id=alert_incident_id, api_version=api_version, - template_url=self.remediate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -359,8 +324,4 @@ def remediate( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - remediate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/alertIncidents/{alertIncidentId}/remediate" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_operation_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_operation_operations.py index 6677021599f0..fc01fa59db58 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alert_operation_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alert_operation_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,13 +44,13 @@ def build_get_request(scope: str, operation_id: str, **kwargs: Any) -> HttpReque # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "operationId": _SERIALIZER.url("operation_id", operation_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -67,19 +67,20 @@ class AlertOperationOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`alert_operation` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOperationResult: @@ -89,12 +90,11 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper :type scope: str :param operation_id: The id of the alert operation. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult + :rtype: ~azure.mgmt.authorization.models.AlertOperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,25 +105,21 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, operation_id=operation_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -132,11 +128,9 @@ def get(self, scope: str, operation_id: str, **kwargs: Any) -> _models.AlertOper map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alerts_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alerts_operations.py index 04c84dc29506..d23346925754 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_alerts_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_alerts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,31 +6,33 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +55,7 @@ def build_get_request(scope: str, alert_id: str, **kwargs: Any) -> HttpRequest: "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +81,7 @@ def build_update_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReques "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +107,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +134,7 @@ def build_refresh_request(scope: str, alert_id: str, **kwargs: Any) -> HttpReque "alertId": _SERIALIZER.url("alert_id", alert_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -156,7 +158,7 @@ def build_refresh_all_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,19 +175,20 @@ class AlertsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_08_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`alerts` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: @@ -200,12 +203,11 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: :type scope: str :param alert_id: The name of the alert to get. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Alert or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert + :rtype: ~azure.mgmt.authorization.models.Alert :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -216,25 +218,21 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -243,17 +241,15 @@ def get(self, scope: str, alert_id: str, **kwargs: Any) -> _models.Alert: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Alert", pipeline_response) + deserialized = self._deserialize("Alert", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return deserialized # type: ignore @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, scope: str, alert_id: str, @@ -269,19 +265,18 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert + :type parameters: ~azure.mgmt.authorization.models.Alert :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + def update( + self, scope: str, alert_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Update an alert. @@ -290,11 +285,10 @@ def update( # pylint: disable=inconsistent-return-statements :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str :param parameters: Parameters for the alert. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +296,7 @@ def update( # pylint: disable=inconsistent-return-statements @distributed_trace def update( # pylint: disable=inconsistent-return-statements - self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO], **kwargs: Any + self, scope: str, alert_id: str, parameters: Union[_models.Alert, IO[bytes]], **kwargs: Any ) -> None: """Update an alert. @@ -310,17 +304,14 @@ def update( # pylint: disable=inconsistent-return-statements :type scope: str :param alert_id: The name of the alert to dismiss. Required. :type alert_id: str - :param parameters: Parameters for the alert. Is either a Alert type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_08_01_preview.models.Alert or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Parameters for the alert. Is either a Alert type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.authorization.models.Alert or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,9 +322,7 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -345,23 +334,21 @@ def update( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(parameters, "Alert") - request = build_update_request( + _request = build_update_request( scope=scope, alert_id=alert_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -371,31 +358,25 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}"} + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> ItemPaged["_models.Alert"]: """Gets alerts for a resource scope. :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Alert or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.Alert] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,33 +387,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.Alert"] def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AlertListResult", pipeline_response) @@ -442,11 +409,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,10 +425,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts"} - - def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,46 +437,43 @@ def _refresh_initial(self, scope: str, alert_id: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( scope=scope, alert_id=alert_id, api_version=api_version, - template_url=self._refresh_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_initial.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return deserialized # type: ignore @distributed_trace def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: @@ -521,26 +483,15 @@ def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_ :type scope: str :param alert_id: The name of the alert to refresh. Required. :type alert_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -555,6 +506,7 @@ def begin_refresh(self, scope: str, alert_id: str, **kwargs: Any) -> LROPoller[_ params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -562,9 +514,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -576,20 +528,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}/refresh" - } + return LROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperationResult: - error_map = { + def _refresh_all_initial(self, scope: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,43 +550,42 @@ def _refresh_all_initial(self, scope: str, **kwargs: Any) -> _models.AlertOperat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) - cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_all_request( + _request = build_refresh_all_request( scope=scope, api_version=api_version, - template_url=self._refresh_all_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _refresh_all_initial.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return deserialized # type: ignore @distributed_trace def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.AlertOperationResult]: @@ -644,26 +593,15 @@ def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.Aler :param scope: The scope of the alert. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either AlertOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertOperationResult] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.authorization.models.AlertOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) cls: ClsType[_models.AlertOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -672,6 +610,7 @@ def begin_refresh_all(self, scope: str, **kwargs: Any) -> LROPoller[_models.Aler raw_result = self._refresh_all_initial( scope=scope, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -679,9 +618,9 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("AlertOperationResult", pipeline_response) + deserialized = self._deserialize("AlertOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -693,12 +632,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AlertOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_all.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/refresh"} + return LROPoller[_models.AlertOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_classic_administrators_operations.py similarity index 62% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_classic_administrators_operations.py index 2723b964e405..9e455bc64247 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_classic_administrators_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,12 +45,12 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,38 +67,37 @@ class ClassicAdministratorsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`classic_administrators` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: + def list(self, **kwargs: Any) -> ItemPaged["_models.ClassicAdministrator"]: """Gets service administrator, account administrator, and co-administrators for the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClassicAdministrator or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.ClassicAdministrator] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,33 +108,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) @@ -146,11 +130,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,5 +146,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_deny_assignments_operations.py similarity index 73% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_deny_assignments_operations.py index e3c38c4ba49e..cb3d47bcd7fe 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_deny_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +57,7 @@ def build_list_for_resource_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( @@ -71,7 +71,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +97,7 @@ def build_list_for_resource_group_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( @@ -105,7 +105,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +133,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +160,7 @@ def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> Htt "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +184,7 @@ def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpReque "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +208,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,19 +227,20 @@ class DenyAssignmentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`deny_assignments` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_resource( @@ -251,7 +252,7 @@ def list_for_resource( resource_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: + ) -> ItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -276,19 +277,17 @@ def list_for_resource( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,7 +298,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -308,30 +307,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -341,11 +326,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,14 +343,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: + ) -> ItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -382,19 +363,17 @@ def list_for_resource_group( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,35 +384,21 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -443,11 +408,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,12 +425,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: + def list(self, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.DenyAssignment"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny @@ -479,19 +440,17 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -502,34 +461,20 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -539,11 +484,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -556,8 +501,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - @distributed_trace def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: """Get the specified deny assignment. @@ -566,12 +509,11 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den :type scope: str :param deny_assignment_id: The ID of the deny assignment to get. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment + :rtype: ~azure.mgmt.authorization.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -582,23 +524,21 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, deny_assignment_id=deny_assignment_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,14 +548,12 @@ def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.Den error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: @@ -627,12 +565,11 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig /providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId} for tenant level deny assignments. Required. :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment + :rtype: ~azure.mgmt.authorization.models.DenyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -643,22 +580,20 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( deny_assignment_id=deny_assignment_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -668,19 +603,17 @@ def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssig error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DenyAssignment", pipeline_response) + deserialized = self._deserialize("DenyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = {"url": "/{denyAssignmentId}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: + ) -> ItemPaged["_models.DenyAssignment"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. Required. @@ -696,19 +629,17 @@ def list_for_scope( ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny assignment name and description properties are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.DenyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -719,34 +650,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) @@ -756,11 +673,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -772,5 +689,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_eligible_child_resources_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_eligible_child_resources_operations.py index 91c9a599883e..d999547226b7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_eligible_child_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +39,7 @@ def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +48,7 @@ def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -68,22 +67,25 @@ class EligibleChildResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EligibleChildResource"]: + def get( + self, scope: str, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. @@ -93,20 +95,18 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,34 +117,20 @@ def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterab def prepare_request(next_link=None): if not next_link: - request = build_get_request( + _request = build_get_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) @@ -154,11 +140,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -169,5 +155,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_global_administrator_operations.py similarity index 73% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_global_administrator_operations.py index 44e2996b346a..509b46334ca9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_global_administrator_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +18,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -59,30 +59,30 @@ class GlobalAdministratorOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`global_administrator` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Elevates access for a Global Administrator. - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,21 +93,19 @@ def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_elevate_access_request( + _request = build_elevate_access_request( api_version=api_version, - template_url=self.elevate_access.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -118,6 +116,4 @@ def elevate_access(self, **kwargs: Any) -> None: # pylint: disable=inconsistent raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - elevate_access.metadata = {"url": "/providers/Microsoft.Authorization/elevateAccess"} + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_operations.py similarity index 61% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_operations.py index 5153ed8f2e57..9af5748f7e79 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -61,39 +60,36 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: """Lists the operations available from this provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,32 +100,18 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -139,11 +121,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,5 +137,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_permissions_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_permissions_operations.py index 5d68e5e0b826..fc182b504448 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_permissions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,14 +40,14 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -55,7 +55,7 @@ def build_list_for_resource_group_request(resource_group_name: str, subscription "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,14 +78,14 @@ def build_list_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 @@ -99,7 +99,7 @@ def build_list_for_resource_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,39 +116,39 @@ class PermissionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: + def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -159,34 +159,20 @@ def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -196,11 +182,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,10 +199,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - @distributed_trace def list_for_resource( self, @@ -226,7 +208,7 @@ def list_for_resource( resource_type: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.Permission"]: + ) -> ItemPaged["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -240,18 +222,17 @@ def list_for_resource( :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -262,7 +243,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, @@ -270,30 +251,16 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) @@ -303,11 +270,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -319,7 +286,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_provider_operations_metadata_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_provider_operations_metadata_operations.py index fa030854e946..280987303bd8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_provider_operations_metadata_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +52,7 @@ def build_get_request(resource_provider_namespace: str, *, expand: str = "resour ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,19 +92,20 @@ class ProviderOperationsMetadataOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`provider_operations_metadata` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -117,12 +117,11 @@ def get( :type resource_provider_namespace: str :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata + :rtype: ~azure.mgmt.authorization.models.ProviderOperationsMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,23 +132,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_provider_namespace=resource_provider_namespace, expand=expand, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,35 +156,32 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} + return deserialized # type: ignore @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: + def list(self, expand: str = "resourceTypes", **kwargs: Any) -> ItemPaged["_models.ProviderOperationsMetadata"]: """Gets provider operations metadata for all resource providers. :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderOperationsMetadata or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.ProviderOperationsMetadata] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,33 +192,19 @@ def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( expand=expand, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) @@ -234,11 +214,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -250,5 +230,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_instances_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_instances_operations.py index e8ca1d811b0b..b4287c1edacc 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +49,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -66,14 +66,14 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleInstanceName": _SERIALIZER.url( @@ -81,7 +81,7 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,30 +92,31 @@ def build_get_request(scope: str, role_assignment_schedule_instance_name: str, * return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleAssignmentScheduleInstancesOperations: +class RoleAssignmentScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentScheduleInstance"]: + ) -> ItemPaged["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. @@ -127,20 +128,19 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -151,34 +151,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) @@ -188,11 +174,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,8 +190,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - @distributed_trace def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any @@ -217,12 +201,11 @@ def get( :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,23 +216,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +239,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_requests_operations.py similarity index 75% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_requests_operations.py index 542edabc6b52..05c60d9322e2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +41,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -49,7 +49,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( @@ -57,7 +57,7 @@ def build_create_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,14 +74,14 @@ def build_get_request(scope: str, role_assignment_schedule_request_name: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( @@ -89,7 +89,7 @@ def build_get_request(scope: str, role_assignment_schedule_request_name: str, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +104,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +113,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -130,14 +130,14 @@ def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( @@ -145,7 +145,7 @@ def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +160,7 @@ def build_validate_request(scope: str, role_assignment_schedule_request_name: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -168,7 +168,7 @@ def build_validate_request(scope: str, role_assignment_schedule_request_name: st _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( @@ -176,7 +176,7 @@ def build_validate_request(scope: str, role_assignment_schedule_request_name: st ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -195,19 +195,20 @@ class RoleAssignmentScheduleRequestsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def create( @@ -232,13 +233,12 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -247,7 +247,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -265,13 +265,12 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -280,7 +279,7 @@ def create( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. @@ -296,18 +295,13 @@ def create( name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +312,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) @@ -330,23 +324,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,16 +347,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -377,12 +365,11 @@ def get( :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,23 +380,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,21 +403,17 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentScheduleRequest"]: + ) -> ItemPaged["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. @@ -445,20 +426,19 @@ def list_for_scope( for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,34 +449,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) @@ -506,11 +472,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,8 +488,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any @@ -535,12 +499,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,23 +514,21 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, - template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +538,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -601,13 +558,12 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -616,7 +572,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -629,13 +585,12 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -644,7 +599,7 @@ def validate( self, scope: str, role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], + parameters: Union[_models.RoleAssignmentScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Validates a new role assignment schedule request. @@ -655,18 +610,13 @@ def validate( validate. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest or IO[bytes] :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,7 +627,7 @@ def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) @@ -689,23 +639,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +662,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedules_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedules_operations.py index a6edd5760f1b..b6b42bf06300 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignment_schedules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,14 +39,14 @@ def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleName": _SERIALIZER.url( @@ -55,7 +54,7 @@ def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +69,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +78,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -98,19 +97,20 @@ class RoleAssignmentSchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> _models.RoleAssignmentSchedule: @@ -121,12 +121,11 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule + :rtype: ~azure.mgmt.authorization.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,23 +136,21 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,21 +159,17 @@ def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) + deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentSchedule"]: + ) -> ItemPaged["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. @@ -188,20 +181,18 @@ def list_for_scope( Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,34 +203,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) @@ -249,11 +226,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,5 +241,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignments_operations.py similarity index 74% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignments_operations.py index 5f8931ac23e9..846bd7c8746d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +54,7 @@ def build_list_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +87,7 @@ def build_list_for_resource_group_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( @@ -95,7 +95,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +131,7 @@ def build_list_for_resource_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( @@ -144,7 +144,7 @@ def build_list_for_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -175,7 +175,7 @@ def build_get_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +203,7 @@ def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -232,7 +232,7 @@ def build_delete_request( "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -265,7 +265,7 @@ def build_list_for_scope_request( "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -295,7 +295,7 @@ def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -322,7 +322,7 @@ def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRe "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -350,7 +350,7 @@ def build_delete_by_id_request( "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -369,24 +369,25 @@ class RoleAssignmentsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: + ) -> ItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role @@ -395,19 +396,17 @@ def list_for_subscription( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,35 +417,21 @@ def list_for_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -456,11 +441,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -473,14 +458,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: + ) -> ItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -492,19 +473,17 @@ def list_for_resource_group( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,36 +494,22 @@ def list_for_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -554,11 +519,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,10 +536,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def list_for_resource( self, @@ -585,7 +546,7 @@ def list_for_resource( filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: + ) -> ItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -604,19 +565,17 @@ def list_for_resource( :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -627,7 +586,7 @@ def list_for_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, @@ -636,30 +595,16 @@ def prepare_request(next_link=None): filter=filter, tenant_id=tenant_id, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -669,11 +614,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -686,10 +631,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -707,12 +648,11 @@ def get( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,24 +663,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -750,14 +688,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @overload def create( @@ -781,13 +717,12 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -796,7 +731,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -813,13 +748,12 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -828,7 +762,7 @@ def create( self, scope: str, role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. @@ -843,18 +777,13 @@ def create( Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters or IO[bytes] :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,7 +794,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) @@ -877,23 +806,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_request( + _request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -903,19 +830,13 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -933,12 +854,11 @@ def delete( :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None + :rtype: ~azure.mgmt.authorization.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -949,24 +869,22 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -978,14 +896,12 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} + return deserialized # type: ignore @distributed_trace def list_for_scope( @@ -995,7 +911,7 @@ def list_for_scope( tenant_id: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: + ) -> ItemPaged["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -1014,19 +930,17 @@ def list_for_scope( return paged role assignments following the skipToken passed. Only supported on provider level calls. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1037,36 +951,22 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, skip_token=skip_token, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) @@ -1076,11 +976,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1093,8 +993,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - @distributed_trace def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1104,17 +1002,17 @@ def get_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1125,23 +1023,21 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1151,14 +1047,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore @overload def create_by_id( @@ -1174,68 +1068,67 @@ def create_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, role_assignment_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any + self, + role_assignment_id: str, + parameters: Union[_models.RoleAssignmentCreateParameters, IO[bytes]], + **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleAssignmentCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleAssignmentCreateParameters or IO[bytes] :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment + :rtype: ~azure.mgmt.authorization.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1246,7 +1139,7 @@ def create_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) @@ -1258,22 +1151,20 @@ def create_by_id( else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - request = build_create_by_id_request( + _request = build_create_by_id_request( role_assignment_id=role_assignment_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1283,19 +1174,13 @@ def create_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - @distributed_trace def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any @@ -1305,17 +1190,17 @@ def delete_by_id( :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. + /subscriptions/\\ :code:``/resourcegroups/\\ + :code:``/providers/Microsoft.Authorization/roleAssignments/\\ + :code:``. Required. :type role_assignment_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment or None + :rtype: ~azure.mgmt.authorization.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1326,23 +1211,21 @@ def delete_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( role_assignment_id=role_assignment_id, tenant_id=tenant_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1354,11 +1237,9 @@ def delete_by_id( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) + deserialized = self._deserialize("RoleAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_definitions_operations.py similarity index 74% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_definitions_operations.py index f214db91e563..467a943e9f97 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_definitions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +76,7 @@ def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> Htt "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +102,7 @@ def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +128,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -154,7 +154,7 @@ def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,19 +171,20 @@ class RoleDefinitionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: @@ -197,12 +198,11 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional :type scope: str :param role_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None + :rtype: ~azure.mgmt.authorization.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,25 +213,21 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -243,14 +239,12 @@ def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional deserialized = None if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: @@ -264,12 +258,11 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol :type scope: str :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -280,25 +273,21 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -308,14 +297,12 @@ def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.Rol error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @overload def create_or_update( @@ -338,13 +325,12 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :type role_definition: ~azure.mgmt.authorization.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -353,7 +339,7 @@ def create_or_update( self, scope: str, role_definition_id: str, - role_definition: IO, + role_definition: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,19 +355,22 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. - :type role_definition: IO + :type role_definition: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any + self, + scope: str, + role_definition_id: str, + role_definition: Union[_models.RoleDefinition, IO[bytes]], + **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. @@ -394,18 +383,13 @@ def create_or_update( :param role_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type role_definition: ~azure.mgmt.authorization.models.RoleDefinition or IO[bytes] :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,9 +400,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) @@ -430,23 +412,21 @@ def create_or_update( else: _json = self._serialize.body(role_definition, "RoleDefinition") - request = build_create_or_update_request( + _request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,17 +436,15 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} + return deserialized # type: ignore @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: + def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -478,21 +456,17 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,34 +477,20 @@ def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Itera def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) @@ -540,11 +500,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -557,8 +517,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. @@ -569,12 +527,11 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition + :rtype: ~azure.mgmt.authorization.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -585,24 +542,20 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( role_id=role_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -612,11 +565,9 @@ def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleDefinition", pipeline_response) + deserialized = self._deserialize("RoleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = {"url": "/{roleId}"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_instances_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_instances_operations.py index 84baa462231c..3fd5aa11016c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +49,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -66,14 +66,14 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleInstanceName": _SERIALIZER.url( @@ -81,7 +81,7 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,30 +92,31 @@ def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleInstancesOperations: +class RoleEligibilityScheduleInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilityScheduleInstance"]: + ) -> ItemPaged["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. @@ -127,20 +128,19 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -151,34 +151,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) @@ -188,11 +174,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,8 +190,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - @distributed_trace def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any @@ -217,12 +201,11 @@ def get( :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,23 +216,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,13 +239,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_requests_operations.py similarity index 75% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_requests_operations.py index 03cb9acf3abe..fcbe45955d2c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedule_requests_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +41,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -49,7 +49,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( @@ -57,7 +57,7 @@ def build_create_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,14 +74,14 @@ def build_get_request(scope: str, role_eligibility_schedule_request_name: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( @@ -89,7 +89,7 @@ def build_get_request(scope: str, role_eligibility_schedule_request_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +104,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +113,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -130,14 +130,14 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( @@ -145,7 +145,7 @@ def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,7 +160,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -168,7 +168,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( @@ -176,7 +176,7 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,25 +189,26 @@ def build_validate_request(scope: str, role_eligibility_schedule_request_name: s return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class RoleEligibilityScheduleRequestsOperations: +class RoleEligibilityScheduleRequestsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def create( @@ -232,13 +233,12 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -247,7 +247,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -265,13 +265,12 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -280,7 +279,7 @@ def create( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. @@ -296,18 +295,13 @@ def create( can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +312,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) @@ -330,23 +324,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_create_request( + _request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,16 +347,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -377,12 +365,11 @@ def get( :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,23 +380,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,21 +403,17 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilityScheduleRequest"]: + ) -> ItemPaged["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. @@ -445,20 +426,19 @@ def list_for_scope( created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -469,34 +449,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) @@ -506,11 +472,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -522,8 +488,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any @@ -535,12 +499,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -551,23 +514,21 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + _request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, - template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,11 +538,7 @@ def cancel( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def validate( @@ -601,13 +558,12 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -616,7 +572,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -629,13 +585,12 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @@ -644,7 +599,7 @@ def validate( self, scope: str, role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], + parameters: Union[_models.RoleEligibilityScheduleRequest, IO[bytes]], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Validates a new role eligibility schedule request. @@ -655,18 +610,13 @@ def validate( validate. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleEligibilityScheduleRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest or IO[bytes] :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :rtype: ~azure.mgmt.authorization.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -677,7 +627,7 @@ def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) @@ -689,23 +639,21 @@ def validate( else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - request = build_validate_request( + _request = build_validate_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,13 +662,9 @@ def validate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedules_operations.py similarity index 69% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedules_operations.py index 9d7ba4e73c05..f9d32c18172e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_eligibility_schedules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,14 +39,14 @@ def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleName": _SERIALIZER.url( @@ -55,7 +54,7 @@ def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +69,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +78,7 @@ def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, ** "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -98,19 +97,20 @@ class RoleEligibilitySchedulesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> _models.RoleEligibilitySchedule: @@ -121,12 +121,11 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule + :rtype: ~azure.mgmt.authorization.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,23 +136,21 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,21 +159,17 @@ def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) + deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } + return deserialized # type: ignore @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilitySchedule"]: + ) -> ItemPaged["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. @@ -188,20 +181,18 @@ def list_for_scope( $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,34 +203,20 @@ def list_for_scope( def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) @@ -249,11 +226,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,5 +241,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policies_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policies_operations.py index 57aa735de0b9..a0e10737b1ab 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,19 +40,19 @@ def build_get_request(scope: str, role_management_policy_name: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,20 +67,20 @@ def build_update_request(scope: str, role_management_policy_name: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,19 +97,19 @@ def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -125,7 +124,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -134,7 +133,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,19 +150,20 @@ class RoleManagementPoliciesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: @@ -174,12 +174,11 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -190,23 +189,21 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +212,12 @@ def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _m map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @overload def update( @@ -244,13 +237,12 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @@ -259,7 +251,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -272,13 +264,12 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @@ -287,7 +278,7 @@ def update( self, scope: str, role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], + parameters: Union[_models.RoleManagementPolicy, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. @@ -298,17 +289,13 @@ def update( Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicy or IO[bytes] :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,7 +306,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) @@ -331,23 +318,21 @@ def update( else: _json = self._serialize.body(parameters, "RoleManagementPolicy") - request = build_update_request( + _request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -356,16 +341,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -378,12 +359,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,23 +374,21 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,32 +398,26 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> ItemPaged["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -456,33 +428,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) @@ -492,11 +450,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,5 +465,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policy_assignments_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policy_assignments_operations.py index d15880273785..5e0c7b014120 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_role_management_policy_assignments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,14 +41,14 @@ def build_get_request(scope: str, role_management_policy_assignment_name: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( @@ -56,7 +56,7 @@ def build_get_request(scope: str, role_management_policy_assignment_name: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -71,7 +71,7 @@ def build_create_request(scope: str, role_management_policy_assignment_name: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -79,7 +79,7 @@ def build_create_request(scope: str, role_management_policy_assignment_name: str _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( @@ -87,7 +87,7 @@ def build_create_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,14 +104,14 @@ def build_delete_request(scope: str, role_management_policy_assignment_name: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( @@ -119,7 +119,7 @@ def build_delete_request(scope: str, role_management_policy_assignment_name: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +134,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,25 +154,26 @@ def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class RoleManagementPolicyAssignmentsOperations: +class RoleManagementPolicyAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -185,12 +186,11 @@ def get( :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -201,23 +201,21 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -226,16 +224,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @overload def create( @@ -255,13 +249,12 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -270,7 +263,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -283,13 +276,12 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @@ -298,7 +290,7 @@ def create( self, scope: str, role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], + parameters: Union[_models.RoleManagementPolicyAssignment, IO[bytes]], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. @@ -309,18 +301,13 @@ def create( management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + RoleManagementPolicyAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment or IO[bytes] :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :rtype: ~azure.mgmt.authorization.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,7 +318,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) @@ -343,23 +330,21 @@ def create( else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - request = build_create_request( + _request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,16 +353,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -390,12 +371,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -406,23 +386,21 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -432,32 +410,27 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: + def list_for_scope(self, scope: str, **kwargs: Any) -> ItemPaged["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01-preview")) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -468,33 +441,19 @@ def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleMan def prepare_request(next_link=None): if not next_link: - request = build_list_for_scope_request( + _request = build_list_for_scope_request( scope=scope, api_version=api_version, - template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) @@ -504,11 +463,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -519,5 +478,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_default_settings_operations.py similarity index 70% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_default_settings_operations.py index 42207206696a..906ecfabb36e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_default_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +48,7 @@ def build_get_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +73,7 @@ def build_put_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,25 +86,26 @@ def build_put_request(scope: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewDefaultSettingsOperations: +class ScopeAccessReviewDefaultSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: @@ -112,12 +113,11 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: :param scope: The scope of the resource. Required. :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,24 +128,20 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( scope=scope, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,14 +151,12 @@ def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore @overload def put( @@ -178,57 +172,49 @@ def put( :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( - self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any + self, scope: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( - self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any + self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleSettings or IO[bytes] :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings + :rtype: ~azure.mgmt.authorization.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,9 +225,7 @@ def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) @@ -253,22 +237,20 @@ def put( else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - request = build_put_request( + _request = build_put_request( scope=scope, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -278,11 +260,9 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) + deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instance_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instance_operations.py index b87d3afdef57..13df20e14ba4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +48,14 @@ def build_generate_download_uri_request( _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,25 +66,26 @@ def build_generate_download_uri_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionInstanceOperations: +class ScopeAccessReviewHistoryDefinitionInstanceOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def generate_download_uri( @@ -99,12 +101,11 @@ def generate_download_uri( :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -115,26 +116,22 @@ def generate_download_uri( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) - request = build_generate_download_uri_request( + _request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, - template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,13 +141,9 @@ def generate_download_uri( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_download_uri.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instances_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instances_operations.py index 04bd6281d819..bed524f0a49c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_instances_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +46,13 @@ def build_list_request(scope: str, history_definition_id: str, **kwargs: Any) -> _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,52 +63,50 @@ def build_list_request(scope: str, history_definition_id: str, **kwargs: Any) -> return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionInstancesOperations: +class ScopeAccessReviewHistoryDefinitionInstancesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewHistoryInstance"]: + ) -> ItemPaged["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,34 +117,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionInstanceListResult", pipeline_response) @@ -157,11 +140,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +156,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_operations.py similarity index 73% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_operations.py index 48311167b09c..dc746f669424 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definition_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +47,13 @@ def build_create_request(scope: str, history_definition_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,13 +77,13 @@ def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,25 +94,26 @@ def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionOperations: +class ScopeAccessReviewHistoryDefinitionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def create( @@ -131,14 +132,12 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -147,7 +146,7 @@ def create( self, scope: str, history_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -159,13 +158,12 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -174,7 +172,7 @@ def create( self, scope: str, history_definition_id: str, - properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], + properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. @@ -184,19 +182,14 @@ def create( :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a - AccessReviewHistoryDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewHistoryDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinitionProperties or + IO[bytes] :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,9 +200,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) @@ -221,23 +212,21 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewHistoryDefinitionProperties") - request = build_create_request( + _request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,16 +236,12 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -268,12 +253,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,25 +268,21 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,8 +293,4 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definitions_operations.py similarity index 68% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definitions_operations.py index 353d0b4774d0..01562670460b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_history_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +19,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +48,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,13 +72,13 @@ def build_get_by_id_request(scope: str, history_definition_id: str, **kwargs: An _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,30 +89,31 @@ def build_get_by_id_request(scope: str, history_definition_id: str, **kwargs: An return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewHistoryDefinitionsOperations: +class ScopeAccessReviewHistoryDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewHistoryDefinition"]: + ) -> ItemPaged["_models.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. @@ -122,22 +122,19 @@ def list( :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,34 +145,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewHistoryDefinitionListResult", pipeline_response) @@ -185,11 +168,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,8 +185,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions"} - @distributed_trace def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. @@ -212,12 +193,11 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,25 +208,21 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,13 +232,9 @@ def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_contacted_reviewers_operations.py similarity index 65% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_contacted_reviewers_operations.py index 1b43fcc8e090..6100f0768ef0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +47,14 @@ def build_list_request(scope: str, schedule_definition_id: str, id: str, **kwarg _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,30 +65,31 @@ def build_list_request(scope: str, schedule_definition_id: str, id: str, **kwarg return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewInstanceContactedReviewersOperations: +class ScopeAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewContactedReviewer"]: + ) -> ItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. @@ -97,22 +98,19 @@ def list( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,35 +121,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -161,11 +145,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -177,7 +161,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_decisions_operations.py similarity index 66% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_decisions_operations.py index b7fb53ea5a5d..2d4e8722b639 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_decisions_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,14 +49,14 @@ def build_list_request( _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -69,30 +69,31 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewInstanceDecisionsOperations: +class ScopeAccessReviewInstanceDecisionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: + ) -> ItemPaged["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. @@ -106,22 +107,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,36 +129,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) @@ -171,11 +154,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -187,7 +170,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_operations.py similarity index 76% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_operations.py index 38813e0e8231..cb25b6fdb06c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instance_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +20,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,14 +47,14 @@ def build_stop_request(scope: str, schedule_definition_id: str, id: str, **kwarg _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,14 +77,14 @@ def build_record_all_decisions_request(scope: str, schedule_definition_id: str, _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,14 +108,14 @@ def build_reset_decisions_request(scope: str, schedule_definition_id: str, id: s _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,14 +137,14 @@ def build_apply_decisions_request(scope: str, schedule_definition_id: str, id: s _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,14 +166,14 @@ def build_send_reminders_request(scope: str, schedule_definition_id: str, id: st _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,19 +190,20 @@ class ScopeAccessReviewInstanceOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -215,12 +217,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -231,26 +232,22 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,14 +258,10 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore @overload - def record_all_decisions( # pylint: disable=inconsistent-return-statements + def record_all_decisions( self, scope: str, schedule_definition_id: str, @@ -287,24 +280,22 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties + :type properties: ~azure.mgmt.authorization.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def record_all_decisions( # pylint: disable=inconsistent-return-statements + def record_all_decisions( self, scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -318,11 +309,10 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -334,7 +324,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.RecordAllDecisionsProperties, IO], + properties: Union[_models.RecordAllDecisionsProperties, IO[bytes]], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. @@ -346,18 +336,13 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type - or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.RecordAllDecisionsProperties or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -368,9 +353,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -382,7 +365,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") - request = build_record_all_decisions_request( + _request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -390,16 +373,14 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,11 +391,7 @@ def record_all_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - record_all_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements @@ -428,12 +405,11 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,26 +420,22 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_decisions_request( + _request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -474,11 +446,7 @@ def reset_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements @@ -492,12 +460,11 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,26 +475,22 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_apply_decisions_request( + _request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -538,11 +501,7 @@ def apply_decisions( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements @@ -556,12 +515,11 @@ def send_reminders( # pylint: disable=inconsistent-return-statements :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -572,26 +530,22 @@ def send_reminders( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_send_reminders_request( + _request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -602,8 +556,4 @@ def send_reminders( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instances_operations.py similarity index 71% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instances_operations.py index 260ac1c153f3..7d20e187f92b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +21,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,13 +50,13 @@ def build_list_request( _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,14 +80,14 @@ def build_get_by_id_request(scope: str, schedule_definition_id: str, id: str, ** _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,14 +110,14 @@ def build_create_request(scope: str, schedule_definition_id: str, id: str, **kwa _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,24 +136,25 @@ class ScopeAccessReviewInstancesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: + ) -> ItemPaged["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. @@ -165,22 +166,18 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewInstance or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,35 +188,21 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) @@ -229,11 +212,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -246,10 +229,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any @@ -262,12 +241,11 @@ def get_by_id( :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,26 +256,22 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,16 +281,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore @overload def create( @@ -338,14 +308,12 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -355,7 +323,7 @@ def create( scope: str, schedule_definition_id: str, id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -369,13 +337,12 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @@ -385,7 +352,7 @@ def create( scope: str, schedule_definition_id: str, id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], + properties: Union[_models.AccessReviewInstanceProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. @@ -397,18 +364,13 @@ def create( :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewInstanceProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewInstanceProperties or IO[bytes] :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance + :rtype: ~azure.mgmt.authorization.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,9 +381,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) @@ -433,7 +393,7 @@ def create( else: _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - request = build_create_request( + _request = build_create_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, @@ -441,16 +401,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +418,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) + deserialized = self._deserialize("AccessReviewInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } + return deserialized # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_schedule_definitions_operations.py similarity index 72% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_schedule_definitions_operations.py index daf22c9b80a3..ac1e457d5d43 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_scope_access_review_schedule_definitions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +49,7 @@ def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: An "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,13 +73,13 @@ def build_get_by_id_request(scope: str, schedule_definition_id: str, **kwargs: A _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,13 +101,13 @@ def build_delete_by_id_request(scope: str, schedule_definition_id: str, **kwargs _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,13 +130,13 @@ def build_create_or_update_by_id_request(scope: str, schedule_definition_id: str _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,13 +160,13 @@ def build_stop_request(scope: str, schedule_definition_id: str, **kwargs: Any) - _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,30 +177,31 @@ def build_stop_request(scope: str, schedule_definition_id: str, **kwargs: Any) - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ScopeAccessReviewScheduleDefinitionsOperations: +class ScopeAccessReviewScheduleDefinitionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewScheduleDefinition"]: + ) -> ItemPaged["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. @@ -211,22 +211,19 @@ def list( $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -237,34 +234,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( scope=scope, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) @@ -274,11 +257,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,8 +274,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} - @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any @@ -303,12 +284,11 @@ def get_by_id( :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,25 +299,21 @@ def get_by_id( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - request = build_get_by_id_request( + _request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,16 +323,12 @@ def get_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements @@ -368,12 +340,11 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,25 +355,21 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_by_id_request( + _request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,11 +380,7 @@ def delete_by_id( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def create_or_update_by_id( @@ -436,14 +399,12 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -452,7 +413,7 @@ def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -464,13 +425,12 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. - :type properties: IO + :type properties: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @@ -479,7 +439,7 @@ def create_or_update_by_id( self, scope: str, schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], + properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO[bytes]], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. @@ -489,19 +449,14 @@ def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + AccessReviewScheduleDefinitionProperties type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinitionProperties or + IO[bytes] :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition + :rtype: ~azure.mgmt.authorization.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,9 +467,7 @@ def create_or_update_by_id( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) @@ -526,23 +479,21 @@ def create_or_update_by_id( else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - request = build_create_or_update_by_id_request( + _request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,16 +503,12 @@ def create_or_update_by_id( error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } + return deserialized # type: ignore @distributed_trace def stop( # pylint: disable=inconsistent-return-statements @@ -573,12 +520,11 @@ def stop( # pylint: disable=inconsistent-return-statements :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -589,25 +535,21 @@ def stop( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, - template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -618,8 +560,4 @@ def stop( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py similarity index 64% rename from sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py rename to sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py index bba1797ba26a..d569d8e57ee4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,15 +20,14 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import AuthorizationManagementClientConfiguration +from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,13 +47,13 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H _url = kwargs.pop( "template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,52 +64,50 @@ def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> H return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class TenantLevelAccessReviewInstanceContactedReviewersOperations: +class TenantLevelAccessReviewInstanceContactedReviewersOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s + :class:`~azure.mgmt.authorization.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AuthorizationManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewContactedReviewer"]: + ) -> ItemPaged["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -120,34 +118,20 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) @@ -157,11 +141,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +157,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py deleted file mode 100644 index f12a37a96c66..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ClassicAdministratorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - definitions and role assignments. A role definition describes the set of actions that can be - performed on resources. A role assignment grants access to Azure Active Directory users. - - :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: - azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py deleted file mode 100644 index c8842b7e5fa2..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2015-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json deleted file mode 100644 index aa6ebd5cdd75..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2015-06-01", - "total_api_version_list": ["2015-06-01"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "classic_administrators": "ClassicAdministratorsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py deleted file mode 100644 index 79efd40a81ac..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ClassicAdministratorsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - definitions and role assignments. A role definition describes the set of actions that can be - performed on resources. A role assignment grants access to Azure Active Directory users. - - :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: - azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-06-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py deleted file mode 100644 index b6f433c3f247..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2015-06-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/__init__.py deleted file mode 100644 index eb44c2838d09..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._classic_administrators_operations import ClassicAdministratorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ClassicAdministratorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py deleted file mode 100644 index 8fc7122b7b46..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._classic_administrators_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ClassicAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_06_01.aio.AuthorizationManagementClient`'s - :attr:`classic_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ClassicAdministrator"]: - """Gets service administrator, account administrator, and co-administrators for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministrator or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) - cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py deleted file mode 100644 index 22ce374ed7ae..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ClassicAdministrator -from ._models_py3 import ClassicAdministratorListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ClassicAdministrator", - "ClassicAdministratorListResult", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py deleted file mode 100644 index 1062cba94c1a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py +++ /dev/null @@ -1,194 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ClassicAdministrator(_serialization.Model): - """Classic Administrators. - - :ivar id: The ID of the administrator. - :vartype id: str - :ivar name: The name of the administrator. - :vartype name: str - :ivar type: The type of the administrator. - :vartype type: str - :ivar email_address: The email address of the administrator. - :vartype email_address: str - :ivar role: The role of the administrator. - :vartype role: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email_address": {"key": "properties.emailAddress", "type": "str"}, - "role": {"key": "properties.role", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - email_address: Optional[str] = None, - role: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The ID of the administrator. - :paramtype id: str - :keyword name: The name of the administrator. - :paramtype name: str - :keyword type: The type of the administrator. - :paramtype type: str - :keyword email_address: The email address of the administrator. - :paramtype email_address: str - :keyword role: The role of the administrator. - :paramtype role: str - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.email_address = email_address - self.role = role - - -class ClassicAdministratorListResult(_serialization.Model): - """ClassicAdministrator list result information. - - :ivar value: An array of administrators. - :vartype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ClassicAdministrator]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ClassicAdministrator"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: An array of administrators. - :paramtype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2015_06_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/__init__.py deleted file mode 100644 index eb44c2838d09..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._classic_administrators_operations import ClassicAdministratorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ClassicAdministratorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py deleted file mode 100644 index 477ad39de894..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py +++ /dev/null @@ -1,166 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ClassicAdministratorsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_06_01.AuthorizationManagementClient`'s - :attr:`classic_administrators` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ClassicAdministrator"]: - """Gets service administrator, account administrator, and co-administrators for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministrator or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-06-01")) - cls: ClsType[_models.ClassicAdministratorListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py deleted file mode 100644 index aaccd7c597f8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py +++ /dev/null @@ -1,131 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - ClassicAdministratorsOperations, - GlobalAdministratorOperations, - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - definitions and role assignments. A role definition describes the set of actions that can be - performed on resources. A role assignment grants access to Azure Active Directory users. - - :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2015_07_01.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations - :ivar global_administrator: GlobalAdministratorOperations operations - :vartype global_administrator: - azure.mgmt.authorization.v2015_07_01.operations.GlobalAdministratorOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations - :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: - azure.mgmt.authorization.v2015_07_01.operations.ClassicAdministratorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py deleted file mode 100644 index 9754fc6dc41c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2015-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json deleted file mode 100644 index a3fd15ea9150..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "chosen_version": "2015-07-01", - "total_api_version_list": ["2015-07-01"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "permissions": "PermissionsOperations", - "role_definitions": "RoleDefinitionsOperations", - "provider_operations_metadata": "ProviderOperationsMetadataOperations", - "global_administrator": "GlobalAdministratorOperations", - "role_assignments": "RoleAssignmentsOperations", - "classic_administrators": "ClassicAdministratorsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py deleted file mode 100644 index 0462fd81915f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py +++ /dev/null @@ -1,131 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - ClassicAdministratorsOperations, - GlobalAdministratorOperations, - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - definitions and role assignments. A role definition describes the set of actions that can be - performed on resources. A role assignment grants access to Azure Active Directory users. - - :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2015_07_01.aio.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2015_07_01.aio.operations.RoleDefinitionsOperations - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2015_07_01.aio.operations.ProviderOperationsMetadataOperations - :ivar global_administrator: GlobalAdministratorOperations operations - :vartype global_administrator: - azure.mgmt.authorization.v2015_07_01.aio.operations.GlobalAdministratorOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2015_07_01.aio.operations.RoleAssignmentsOperations - :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: - azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize, "2015-07-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py deleted file mode 100644 index 05ba4ebb00d5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2015-07-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/__init__.py deleted file mode 100644 index 5e4c27bb4cc7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._global_administrator_operations import GlobalAdministratorOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._classic_administrators_operations import ClassicAdministratorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PermissionsOperations", - "RoleDefinitionsOperations", - "ProviderOperationsMetadataOperations", - "GlobalAdministratorOperations", - "RoleAssignmentsOperations", - "ClassicAdministratorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py deleted file mode 100644 index c8d93d2e80ad..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py +++ /dev/null @@ -1,984 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignments_operations import ( - build_create_by_id_request, - build_create_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace_async - async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - async def create_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace_async - async def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py deleted file mode 100644 index e53afe0a419e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py +++ /dev/null @@ -1,463 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_definitions_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.aio.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace_async - async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace_async - async def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_definition_id: 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. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleDefinitionId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py deleted file mode 100644 index 476bc48f5b50..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py +++ /dev/null @@ -1,56 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ClassicAdministrator -from ._models_py3 import ClassicAdministratorListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Permission -from ._models_py3 import PermissionGetResult -from ._models_py3 import ProviderOperation -from ._models_py3 import ProviderOperationsMetadata -from ._models_py3 import ProviderOperationsMetadataListResult -from ._models_py3 import ResourceType -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult -from ._models_py3 import RoleAssignmentProperties -from ._models_py3 import RoleAssignmentPropertiesWithScope -from ._models_py3 import RoleDefinition -from ._models_py3 import RoleDefinitionFilter -from ._models_py3 import RoleDefinitionListResult -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ClassicAdministrator", - "ClassicAdministratorListResult", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Permission", - "PermissionGetResult", - "ProviderOperation", - "ProviderOperationsMetadata", - "ProviderOperationsMetadataListResult", - "ResourceType", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "RoleAssignmentProperties", - "RoleAssignmentPropertiesWithScope", - "RoleDefinition", - "RoleDefinitionFilter", - "RoleDefinitionListResult", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py deleted file mode 100644 index 6cb02fbd54fe..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py +++ /dev/null @@ -1,754 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 sys -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ClassicAdministrator(_serialization.Model): - """Classic Administrators. - - :ivar id: The ID of the administrator. - :vartype id: str - :ivar name: The name of the administrator. - :vartype name: str - :ivar type: The type of the administrator. - :vartype type: str - :ivar email_address: The email address of the administrator. - :vartype email_address: str - :ivar role: The role of the administrator. - :vartype role: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email_address": {"key": "properties.emailAddress", "type": "str"}, - "role": {"key": "properties.role", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - email_address: Optional[str] = None, - role: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The ID of the administrator. - :paramtype id: str - :keyword name: The name of the administrator. - :paramtype name: str - :keyword type: The type of the administrator. - :paramtype type: str - :keyword email_address: The email address of the administrator. - :paramtype email_address: str - :keyword role: The role of the administrator. - :paramtype role: str - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.email_address = email_address - self.role = role - - -class ClassicAdministratorListResult(_serialization.Model): - """ClassicAdministrator list result information. - - :ivar value: An array of administrators. - :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ClassicAdministrator]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ClassicAdministrator"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: An array of administrators. - :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2015_07_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - } - - def __init__( - self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - - -class PermissionGetResult(_serialization.Model): - """Permissions information. - - :ivar value: An array of permissions. - :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Permission]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: An array of permissions. - :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProviderOperation(_serialization.Model): - """Operation. - - :ivar name: The operation name. - :vartype name: str - :ivar display_name: The operation display name. - :vartype display_name: str - :ivar description: The operation description. - :vartype description: str - :ivar origin: The operation origin. - :vartype origin: str - :ivar properties: The operation properties. - :vartype properties: JSON - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "object"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - origin: Optional[str] = None, - properties: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The operation name. - :paramtype name: str - :keyword display_name: The operation display name. - :paramtype display_name: str - :keyword description: The operation description. - :paramtype description: str - :keyword origin: The operation origin. - :paramtype origin: str - :keyword properties: The operation properties. - :paramtype properties: JSON - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.description = description - self.origin = origin - self.properties = properties - - -class ProviderOperationsMetadata(_serialization.Model): - """Provider Operations metadata. - - :ivar id: The provider id. - :vartype id: str - :ivar name: The provider name. - :vartype name: str - :ivar type: The provider type. - :vartype type: str - :ivar display_name: The provider display name. - :vartype display_name: str - :ivar resource_types: The provider resource types. - :vartype resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :ivar operations: The provider operations. - :vartype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - display_name: Optional[str] = None, - resource_types: Optional[List["_models.ResourceType"]] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The provider id. - :paramtype id: str - :keyword name: The provider name. - :paramtype name: str - :keyword type: The provider type. - :paramtype type: str - :keyword display_name: The provider display name. - :paramtype display_name: str - :keyword resource_types: The provider resource types. - :paramtype resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :keyword operations: The provider operations. - :paramtype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.display_name = display_name - self.resource_types = resource_types - self.operations = operations - - -class ProviderOperationsMetadataListResult(_serialization.Model): - """Provider operations metadata list. - - :ivar value: The list of providers. - :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ProviderOperationsMetadata"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of providers. - :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceType(_serialization.Model): - """Resource Type. - - :ivar name: The resource type name. - :vartype name: str - :ivar display_name: The resource type display name. - :vartype display_name: str - :ivar operations: The resource type operations. - :vartype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The resource type name. - :paramtype name: str - :keyword display_name: The resource type display name. - :paramtype display_name: str - :keyword operations: The resource type operations. - :paramtype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.operations = operations - - -class RoleAssignment(_serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar properties: Role assignment properties. - :vartype properties: - ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "properties": {"key": "properties", "type": "RoleAssignmentPropertiesWithScope"}, - } - - def __init__( - self, *, properties: Optional["_models.RoleAssignmentPropertiesWithScope"] = None, **kwargs: Any - ) -> None: - """ - :keyword properties: Role assignment properties. - :paramtype properties: - ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - - -class RoleAssignmentCreateParameters(_serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :ivar properties: Role assignment properties. Required. - :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties - """ - - _validation = { - "properties": {"required": True}, - } - - _attribute_map = { - "properties": {"key": "properties", "type": "RoleAssignmentProperties"}, - } - - def __init__(self, *, properties: "_models.RoleAssignmentProperties", **kwargs: Any) -> None: - """ - :keyword properties: Role assignment properties. Required. - :paramtype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties - """ - super().__init__(**kwargs) - self.properties = properties - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentProperties(_serialization.Model): - """Role assignment properties. - - All required parameters must be populated in order to send to Azure. - - :ivar role_definition_id: The role definition ID used in the role assignment. Required. - :vartype role_definition_id: str - :ivar principal_id: 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. Required. - :vartype principal_id: str - """ - - _validation = { - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - } - - _attribute_map = { - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__(self, *, role_definition_id: str, principal_id: str, **kwargs: Any) -> None: - """ - :keyword role_definition_id: The role definition ID used in the role assignment. Required. - :paramtype role_definition_id: str - :keyword principal_id: 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. Required. - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.role_definition_id = role_definition_id - self.principal_id = principal_id - - -class RoleAssignmentPropertiesWithScope(_serialization.Model): - """Role assignment properties with scope. - - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - - -class RoleDefinition(_serialization.Model): - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :ivar role_name: The role name. - :vartype role_name: str - :ivar description: The role definition description. - :vartype description: str - :ivar role_type: The role type. - :vartype role_type: str - :ivar permissions: Role definition permissions. - :vartype permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :ivar assignable_scopes: Role definition assignable scopes. - :vartype assignable_scopes: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "role_name": {"key": "properties.roleName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "role_type": {"key": "properties.type", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[Permission]"}, - "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - } - - def __init__( - self, - *, - role_name: Optional[str] = None, - description: Optional[str] = None, - role_type: Optional[str] = None, - permissions: Optional[List["_models.Permission"]] = None, - assignable_scopes: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_name: The role name. - :paramtype role_name: str - :keyword description: The role definition description. - :paramtype description: str - :keyword role_type: The role type. - :paramtype role_type: str - :keyword permissions: Role definition permissions. - :paramtype permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :keyword assignable_scopes: Role definition assignable scopes. - :paramtype assignable_scopes: list[str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = role_name - self.description = description - self.role_type = role_type - self.permissions = permissions - self.assignable_scopes = assignable_scopes - - -class RoleDefinitionFilter(_serialization.Model): - """Role Definitions filter. - - :ivar role_name: Returns role definition with the specific name. - :vartype role_name: str - """ - - _attribute_map = { - "role_name": {"key": "roleName", "type": "str"}, - } - - def __init__(self, *, role_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword role_name: Returns role definition with the specific name. - :paramtype role_name: str - """ - super().__init__(**kwargs) - self.role_name = role_name - - -class RoleDefinitionListResult(_serialization.Model): - """Role definition list operation result. - - :ivar value: Role definition list. - :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role definition list. - :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/__init__.py deleted file mode 100644 index 5e4c27bb4cc7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._global_administrator_operations import GlobalAdministratorOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._classic_administrators_operations import ClassicAdministratorsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PermissionsOperations", - "RoleDefinitionsOperations", - "ProviderOperationsMetadataOperations", - "GlobalAdministratorOperations", - "RoleAssignmentsOperations", - "ClassicAdministratorsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py deleted file mode 100644 index 947f26d65d70..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py +++ /dev/null @@ -1,323 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py deleted file mode 100644 index 227deda6a6df..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py +++ /dev/null @@ -1,252 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_provider_namespace: str, *, expand: str = "resourceTypes", **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}" - ) - path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(*, expand: str = "resourceTypes", **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ProviderOperationsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s - :attr:`provider_operations_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_provider_namespace: str, expand: str = "resourceTypes", **kwargs: Any - ) -> _models.ProviderOperationsMetadata: - """Gets provider operations metadata for the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - - request = build_get_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} - - @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: - """Gets provider operations metadata for all resource providers. - - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadata or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - expand=expand, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py deleted file mode 100644 index f84bbdb3cb5c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1262 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, "str"), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def delete_by_id(self, role_assignment_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - def create_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace - def get_by_id(self, role_assignment_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, - resource name and resource type. Use the format, - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. - Required. - :type role_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py deleted file mode 100644 index 209215e725ac..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py +++ /dev/null @@ -1,587 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleDefinitionId}") - path_format_arguments = { - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2015_07_01.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace - def get_by_id(self, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_definition_id: 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. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2015-07-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleDefinitionId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py deleted file mode 100644 index 5ad48e5dacbd..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These calls handle provider operations. - - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations - :ivar permissions: PermissionsOperations operations - :vartype permissions: - azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py deleted file mode 100644 index 3a5e01a9072a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json deleted file mode 100644 index 9a806fbd35d2..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2018-01-01-preview", - "total_api_version_list": ["2018-01-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These calls handle provider operations.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "provider_operations_metadata": "ProviderOperationsMetadataOperations", - "role_assignments": "RoleAssignmentsOperations", - "permissions": "PermissionsOperations", - "role_definitions": "RoleDefinitionsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 3925e922add3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These calls handle provider operations. - - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2018_01_01_preview.aio.operations.ProviderOperationsMetadataOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleAssignmentsOperations - :ivar permissions: PermissionsOperations operations - :vartype permissions: - azure.mgmt.authorization.v2018_01_01_preview.aio.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py deleted file mode 100644 index b2152db43266..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index 0185ff6c9bb0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ProviderOperationsMetadataOperations", - "RoleAssignmentsOperations", - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py deleted file mode 100644 index 6e00acd23c6b..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py +++ /dev/null @@ -1,254 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py deleted file mode 100644 index 496995dc7849..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py +++ /dev/null @@ -1,205 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._provider_operations_metadata_operations import build_get_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProviderOperationsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`provider_operations_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_provider_namespace: str, expand: str = "resourceTypes", **kwargs: Any - ) -> _models.ProviderOperationsMetadata: - """Gets provider operations metadata for the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - - request = build_get_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} - - @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: - """Gets provider operations metadata for all resource providers. - - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadata or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - expand=expand, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py deleted file mode 100644 index 8f68827c9436..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py +++ /dev/null @@ -1,986 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignments_operations import ( - build_create_by_id_request, - build_create_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace_async - async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - async def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace_async - async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py deleted file mode 100644 index d90764340cff..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py +++ /dev/null @@ -1,474 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_definitions_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace_async - async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace_async - async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_id: 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. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py deleted file mode 100644 index 402dae854cc4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Permission -from ._models_py3 import PermissionGetResult -from ._models_py3 import ProviderOperation -from ._models_py3 import ProviderOperationsMetadata -from ._models_py3 import ProviderOperationsMetadataListResult -from ._models_py3 import ResourceType -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult -from ._models_py3 import RoleDefinition -from ._models_py3 import RoleDefinitionFilter -from ._models_py3 import RoleDefinitionListResult -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Permission", - "PermissionGetResult", - "ProviderOperation", - "ProviderOperationsMetadata", - "ProviderOperationsMetadataListResult", - "ResourceType", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "RoleDefinition", - "RoleDefinitionFilter", - "RoleDefinitionListResult", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py deleted file mode 100644 index 03998151c3c9..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,681 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 sys -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class PermissionGetResult(_serialization.Model): - """Permissions information. - - :ivar value: An array of permissions. - :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Permission]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: An array of permissions. - :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ProviderOperation(_serialization.Model): - """Operation. - - :ivar name: The operation name. - :vartype name: str - :ivar display_name: The operation display name. - :vartype display_name: str - :ivar description: The operation description. - :vartype description: str - :ivar origin: The operation origin. - :vartype origin: str - :ivar properties: The operation properties. - :vartype properties: JSON - :ivar is_data_action: The dataAction flag to specify the operation type. - :vartype is_data_action: bool - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "object"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - origin: Optional[str] = None, - properties: Optional[JSON] = None, - is_data_action: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The operation name. - :paramtype name: str - :keyword display_name: The operation display name. - :paramtype display_name: str - :keyword description: The operation description. - :paramtype description: str - :keyword origin: The operation origin. - :paramtype origin: str - :keyword properties: The operation properties. - :paramtype properties: JSON - :keyword is_data_action: The dataAction flag to specify the operation type. - :paramtype is_data_action: bool - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.description = description - self.origin = origin - self.properties = properties - self.is_data_action = is_data_action - - -class ProviderOperationsMetadata(_serialization.Model): - """Provider Operations metadata. - - :ivar id: The provider id. - :vartype id: str - :ivar name: The provider name. - :vartype name: str - :ivar type: The provider type. - :vartype type: str - :ivar display_name: The provider display name. - :vartype display_name: str - :ivar resource_types: The provider resource types. - :vartype resource_types: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :ivar operations: The provider operations. - :vartype operations: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - display_name: Optional[str] = None, - resource_types: Optional[List["_models.ResourceType"]] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The provider id. - :paramtype id: str - :keyword name: The provider name. - :paramtype name: str - :keyword type: The provider type. - :paramtype type: str - :keyword display_name: The provider display name. - :paramtype display_name: str - :keyword resource_types: The provider resource types. - :paramtype resource_types: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :keyword operations: The provider operations. - :paramtype operations: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.display_name = display_name - self.resource_types = resource_types - self.operations = operations - - -class ProviderOperationsMetadataListResult(_serialization.Model): - """Provider operations metadata list. - - :ivar value: The list of providers. - :vartype value: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ProviderOperationsMetadata"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of providers. - :paramtype value: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceType(_serialization.Model): - """Resource Type. - - :ivar name: The resource type name. - :vartype name: str - :ivar display_name: The resource type display name. - :vartype display_name: str - :ivar operations: The resource type operations. - :vartype operations: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The resource type name. - :paramtype name: str - :keyword display_name: The resource type display name. - :paramtype display_name: str - :keyword operations: The resource type operations. - :paramtype operations: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.operations = operations - - -class RoleAssignment(_serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - can_delegate: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.can_delegate = can_delegate - - -class RoleAssignmentCreateParameters(_serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :ivar role_definition_id: The role definition ID used in the role assignment. Required. - :vartype role_definition_id: str - :ivar principal_id: 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. Required. - :vartype principal_id: str - :ivar can_delegate: The delegation flag used for creating a role assignment. - :vartype can_delegate: bool - """ - - _validation = { - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - } - - _attribute_map = { - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - } - - def __init__( - self, *, role_definition_id: str, principal_id: str, can_delegate: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID used in the role assignment. Required. - :paramtype role_definition_id: str - :keyword principal_id: 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. Required. - :paramtype principal_id: str - :keyword can_delegate: The delegation flag used for creating a role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.can_delegate = can_delegate - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "can_delegate": {"key": "canDelegate", "type": "bool"}, - } - - def __init__( - self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.can_delegate = can_delegate - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleDefinition(_serialization.Model): - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :ivar role_name: The role name. - :vartype role_name: str - :ivar description: The role definition description. - :vartype description: str - :ivar role_type: The role type. - :vartype role_type: str - :ivar permissions: Role definition permissions. - :vartype permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :ivar assignable_scopes: Role definition assignable scopes. - :vartype assignable_scopes: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "role_name": {"key": "properties.roleName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "role_type": {"key": "properties.type", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[Permission]"}, - "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - } - - def __init__( - self, - *, - role_name: Optional[str] = None, - description: Optional[str] = None, - role_type: Optional[str] = None, - permissions: Optional[List["_models.Permission"]] = None, - assignable_scopes: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_name: The role name. - :paramtype role_name: str - :keyword description: The role definition description. - :paramtype description: str - :keyword role_type: The role type. - :paramtype role_type: str - :keyword permissions: Role definition permissions. - :paramtype permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :keyword assignable_scopes: Role definition assignable scopes. - :paramtype assignable_scopes: list[str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = role_name - self.description = description - self.role_type = role_type - self.permissions = permissions - self.assignable_scopes = assignable_scopes - - -class RoleDefinitionFilter(_serialization.Model): - """Role Definitions filter. - - :ivar role_name: Returns role definition with the specific name. - :vartype role_name: str - :ivar type: Returns role definition with the specific type. - :vartype type: str - """ - - _attribute_map = { - "role_name": {"key": "roleName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword role_name: Returns role definition with the specific name. - :paramtype role_name: str - :keyword type: Returns role definition with the specific type. - :paramtype type: str - """ - super().__init__(**kwargs) - self.role_name = role_name - self.type = type - - -class RoleDefinitionListResult(_serialization.Model): - """Role definition list operation result. - - :ivar value: Role definition list. - :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role definition list. - :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/__init__.py deleted file mode 100644 index 0185ff6c9bb0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ProviderOperationsMetadataOperations", - "RoleAssignmentsOperations", - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py deleted file mode 100644 index ec916a24c3f5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py +++ /dev/null @@ -1,331 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py deleted file mode 100644 index c447ad8b13c5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py +++ /dev/null @@ -1,258 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(resource_provider_namespace: str, *, expand: str = "resourceTypes", **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}" - ) - path_format_arguments = { - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(*, expand: str = "resourceTypes", **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ProviderOperationsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.AuthorizationManagementClient`'s - :attr:`provider_operations_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, resource_provider_namespace: str, expand: str = "resourceTypes", **kwargs: Any - ) -> _models.ProviderOperationsMetadata: - """Gets provider operations metadata for the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - - request = build_get_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} - - @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> Iterable["_models.ProviderOperationsMetadata"]: - """Gets provider operations metadata for all resource providers. - - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadata or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - expand=expand, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py deleted file mode 100644 index 455091767542..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1266 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py deleted file mode 100644 index ac7d84073fdb..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py +++ /dev/null @@ -1,598 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_01_01_preview.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace - def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_id: 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. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-01-01-preview") - ) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py deleted file mode 100644 index e80e2c8a5e3c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceMyDecisionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py deleted file mode 100644 index 676d7f01a754..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json deleted file mode 100644 index aefc25530dbf..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "chosen_version": "2018-05-01-preview", - "total_api_version_list": ["2018-05-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "access_review_schedule_definitions": "AccessReviewScheduleDefinitionsOperations", - "access_review_instances": "AccessReviewInstancesOperations", - "access_review_instance": "AccessReviewInstanceOperations", - "access_review_instance_decisions": "AccessReviewInstanceDecisionsOperations", - "access_review_default_settings": "AccessReviewDefaultSettingsOperations", - "access_review_schedule_definitions_assigned_for_my_approval": "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "access_review_instances_assigned_for_my_approval": "AccessReviewInstancesAssignedForMyApprovalOperations", - "access_review_instance_my_decisions": "AccessReviewInstanceMyDecisionsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 0d346caa3a09..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py deleted file mode 100644 index 11425fcc1e0e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index 0bb9a6bebd04..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py deleted file mode 100644 index 4093f9122e0d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_default_settings_operations import build_get_request, build_put_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - async def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index 73ed017371b3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_decisions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index ab73f5220fa7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_my_decisions_operations import ( - build_get_by_id_request, - build_list_request, - build_patch_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace_async - async def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py deleted file mode 100644 index f48d95fd5364..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,367 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_operations import ( - build_accept_recommendations_request, - build_apply_decisions_request, - build_reset_decisions_request, - build_send_reminders_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace_async - async def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace_async - async def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace_async - async def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace_async - async def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index 851f3ad97599..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,210 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_assigned_for_my_approval_operations import ( - build_get_by_id_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py deleted file mode 100644 index 486b19bc7043..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,209 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_operations import build_get_by_id_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, **kwargs: Any) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index efcd59d346a3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index 8a2c955b98db..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,458 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_operations import ( - build_create_or_update_by_id_request, - build_delete_by_id_request, - build_get_by_id_request, - build_list_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py deleted file mode 100644 index 70974ee792c4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py deleted file mode 100644 index 62c0a076e536..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AccessReviewDecision -from ._models_py3 import AccessReviewDecisionListResult -from ._models_py3 import AccessReviewDecisionProperties -from ._models_py3 import AccessReviewDecisionTarget -from ._models_py3 import AccessReviewDefaultSettings -from ._models_py3 import AccessReviewInstance -from ._models_py3 import AccessReviewInstanceListResult -from ._models_py3 import AccessReviewReviewer -from ._models_py3 import AccessReviewScheduleDefinition -from ._models_py3 import AccessReviewScheduleDefinitionListResult -from ._models_py3 import AccessReviewScheduleDefinitionProperties -from ._models_py3 import AccessReviewScheduleSettings -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorDefinitionProperties -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import ServicePrincipalDecisionTarget -from ._models_py3 import UserDecisionTarget - -from ._authorization_management_client_enums import AccessRecommendationType -from ._authorization_management_client_enums import AccessReviewActorIdentityType -from ._authorization_management_client_enums import AccessReviewApplyResult -from ._authorization_management_client_enums import AccessReviewInstanceStatus -from ._authorization_management_client_enums import AccessReviewRecurrencePatternType -from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType -from ._authorization_management_client_enums import AccessReviewResult -from ._authorization_management_client_enums import AccessReviewReviewerType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus -from ._authorization_management_client_enums import AccessReviewScopePrincipalType -from ._authorization_management_client_enums import DecisionTargetType -from ._authorization_management_client_enums import DefaultDecisionType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessReviewDecision", - "AccessReviewDecisionListResult", - "AccessReviewDecisionProperties", - "AccessReviewDecisionTarget", - "AccessReviewDefaultSettings", - "AccessReviewInstance", - "AccessReviewInstanceListResult", - "AccessReviewReviewer", - "AccessReviewScheduleDefinition", - "AccessReviewScheduleDefinitionListResult", - "AccessReviewScheduleDefinitionProperties", - "AccessReviewScheduleSettings", - "ErrorDefinition", - "ErrorDefinitionProperties", - "Operation", - "OperationDisplay", - "OperationListResult", - "ServicePrincipalDecisionTarget", - "UserDecisionTarget", - "AccessRecommendationType", - "AccessReviewActorIdentityType", - "AccessReviewApplyResult", - "AccessReviewInstanceStatus", - "AccessReviewRecurrencePatternType", - "AccessReviewRecurrenceRangeType", - "AccessReviewResult", - "AccessReviewReviewerType", - "AccessReviewScheduleDefinitionReviewersType", - "AccessReviewScheduleDefinitionStatus", - "AccessReviewScopePrincipalType", - "DecisionTargetType", - "DefaultDecisionType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index 27bfa98670e0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,135 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessRecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The feature- generated recommendation shown to the reviewer.""" - - APPROVE = "Approve" - DENY = "Deny" - NO_INFO_AVAILABLE = "NoInfoAvailable" - - -class AccessReviewActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewApplyResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The outcome of applying the decision.""" - - NEW = "New" - APPLYING = "Applying" - APPLIED_SUCCESSFULLY = "AppliedSuccessfully" - APPLIED_WITH_UNKNOWN_FAILURE = "AppliedWithUnknownFailure" - APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" - APPLY_NOT_SUPPORTED = "ApplyNotSupported" - - -class AccessReviewInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an access review instance.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewRecurrencePatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence type : weekly, monthly, etc.""" - - WEEKLY = "weekly" - ABSOLUTE_MONTHLY = "absoluteMonthly" - - -class AccessReviewRecurrenceRangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence range type. The possible values are: endDate, noEnd, numbered.""" - - END_DATE = "endDate" - NO_END = "noEnd" - NUMBERED = "numbered" - - -class AccessReviewResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The decision on the approval step. This value is initially set to NotReviewed. Approvers can - take action of Approve/Deny. - """ - - APPROVE = "Approve" - DENY = "Deny" - NOT_REVIEWED = "NotReviewed" - DONT_KNOW = "DontKnow" - NOT_NOTIFIED = "NotNotified" - - -class AccessReviewReviewerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewScheduleDefinitionReviewersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - ASSIGNED = "Assigned" - SELF = "Self" - MANAGERS = "Managers" - - -class AccessReviewScheduleDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an accessReview.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type user/servicePrincipal to review.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class DecisionTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of decision target : User/ServicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This specifies the behavior for the autoReview feature when an access review completes.""" - - APPROVE = "Approve" - DENY = "Deny" - RECOMMENDATION = "Recommendation" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py deleted file mode 100644 index 1440b3c8986f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1612 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :ivar type_properties_target_type: The type of decision target : User/ServicePrincipal. Known - values are: "user" and "servicePrincipal". - :vartype type_properties_target_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_properties_applied_by_principal_id": {"readonly": True}, - "principal_type_properties_applied_by_principal_type": {"readonly": True}, - "principal_name_properties_applied_by_principal_name": {"readonly": True}, - "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, - "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, - "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, - "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "recommendation": {"key": "properties.recommendation", "type": "str"}, - "decision": {"key": "properties.decision", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "properties.applyResult", "type": "str"}, - "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, - "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, - "principal_type_properties_applied_by_principal_type": { - "key": "properties.appliedBy.principalType", - "type": "str", - }, - "principal_name_properties_applied_by_principal_name": { - "key": "properties.appliedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_applied_by_user_principal_name": { - "key": "properties.appliedBy.userPrincipalName", - "type": "str", - }, - "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, - "principal_type_properties_reviewed_by_principal_type": { - "key": "properties.reviewedBy.principalType", - "type": "str", - }, - "principal_name_properties_reviewed_by_principal_name": { - "key": "properties.reviewedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_reviewed_by_user_principal_name": { - "key": "properties.reviewedBy.userPrincipalName", - "type": "str", - }, - "type_properties_target_type": {"key": "properties.target.type", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_target_type: Optional[str] = None - - -class AccessReviewDecisionListResult(_serialization.Model): - """List of access review decisions. - - :ivar value: Access Review Decision list. - :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewDecision]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewDecision"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Decision list. - :paramtype value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :ivar type: The type of decision target : User/ServicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_applied_by_principal_id": {"readonly": True}, - "principal_type_applied_by_principal_type": {"readonly": True}, - "principal_name_applied_by_principal_name": {"readonly": True}, - "user_principal_name_applied_by_user_principal_name": {"readonly": True}, - "principal_id_reviewed_by_principal_id": {"readonly": True}, - "principal_type_reviewed_by_principal_type": {"readonly": True}, - "principal_name_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "recommendation": {"key": "recommendation", "type": "str"}, - "decision": {"key": "decision", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "applyResult", "type": "str"}, - "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, - "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, - "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, - "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, - "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, - "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, - "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, - "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, - "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, - "type": {"key": "target.type", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type: Optional[str] = None - - -class AccessReviewDecisionTarget(_serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ServicePrincipalDecisionTarget, UserDecisionTarget - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"servicePrincipal": "ServicePrincipalDecisionTarget", "user": "UserDecisionTarget"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "properties.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, - "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_recurrence_range_type = type_properties_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type - self.interval = interval - - -class AccessReviewInstance(_serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - - -class AccessReviewInstanceListResult(_serialization.Model): - """List of Access Review Instances. - - :ivar value: Access Review Instance list. - :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewReviewer(_serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The id of the reviewer(user/servicePrincipal). - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - "principal_type": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: The id of the reviewer(user/servicePrincipal). - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.principal_type = None - - -class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_properties_scope_principal_type": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_properties_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, - "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": { - "key": "properties.settings.justificationRequiredOnApproval", - "type": "bool", - }, - "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, - "type_properties_settings_recurrence_range_type": { - "key": "properties.settings.recurrence.range.type", - "type": "str", - }, - "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_settings_recurrence_pattern_type": { - "key": "properties.settings.recurrence.pattern.type", - "type": "str", - }, - "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, - "principal_type_properties_created_by_principal_type": { - "key": "properties.createdBy.principalType", - "type": "str", - }, - "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_settings_recurrence_range_type: Optional[ - Union[str, "_models.AccessReviewRecurrenceRangeType"] - ] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_settings_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The - possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and - "numbered". - :paramtype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, - monthly, etc. Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(_serialization.Model): - """List of Access Review Schedule Definitions. - - :ivar value: Access Review Schedule Definition list. - :vartype value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Schedule Definition list. - :paramtype value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known - values are: "weekly" and "absoluteMonthly". - :vartype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_scope_principal_type": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, - "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, - "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, - "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "createdBy.principalId", "type": "str"}, - "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, - "principal_name": {"key": "createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_settings_recurrence_range_type = type_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Settings of an Access Review. - - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :vartype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _attribute_map = { - "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, - "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, - "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, - "interval": {"key": "recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :paramtype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_recurrence_range_type = type_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_recurrence_pattern_type = type_recurrence_pattern_type - self.interval = interval - - -class ErrorDefinition(_serialization.Model): - """Error description and code explaining why an operation failed. - - :ivar error: Error of the list gateway status. - :vartype error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionProperties"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error of the list gateway status. - :paramtype error: - ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorDefinitionProperties(_serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :ivar code: Error code of list gateway. - :vartype code: str - """ - - _validation = { - "message": {"readonly": True}, - } - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code of list gateway. - :paramtype code: str - """ - super().__init__(**kwargs) - self.message = None - self.code = code - - -class Operation(_serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :ivar name: Name of the operation. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :ivar origin: Origin of the operation. - :vartype origin: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation. - :paramtype name: str - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :keyword origin: Origin of the operation. - :paramtype origin: str - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - - -class OperationDisplay(_serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection value. - :paramtype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :keyword next_link: The URI that can be used to request the next set of paged results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ServicePrincipalDecisionTarget(AccessReviewDecisionTarget): - """Service Principal Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - :ivar principal_id: The id of service principal whose access is reviewed. - :vartype principal_id: str - :ivar principal_name: The display name of the service principal whose access was reviewed. - :vartype principal_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - "type": {"required": True}, - "principal_id": {"readonly": True}, - "principal_name": {"readonly": True}, - "app_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "principal_name": {"key": "principalName", "type": "str"}, - "app_id": {"key": "appId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "servicePrincipal" - self.principal_id = None - self.principal_name = None - self.app_id = None - - -class UserDecisionTarget(AccessReviewDecisionTarget): - """User Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - :ivar principal_id: The id of user whose access was reviewed. - :vartype principal_id: str - :ivar principal_name: The display name of the user whose access was reviewed. - :vartype principal_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - "type": {"required": True}, - "principal_id": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "principal_name": {"key": "principalName", "type": "str"}, - "user_principal_name": {"key": "userPrincipalName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "user" - self.principal_id = None - self.principal_name = None - self.user_principal_name = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/__init__.py deleted file mode 100644 index 0bb9a6bebd04..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py deleted file mode 100644 index 5eb5975a1621..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index 1c86e8c0737f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,179 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index b2b8dae079ef..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,460 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, id: str, **kwargs: Any) -> Iterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace - def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py deleted file mode 100644 index 1b5d7c5a7588..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,514 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_stop_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_reset_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_apply_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_send_reminders_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_accept_recommendations_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace - def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace - def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace - def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace - def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index 4f262f516dfa..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,264 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py deleted file mode 100644 index e944e31089c8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,268 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, schedule_definition_id: str, **kwargs: Any) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index ebc0067a2fd3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index f426bc61978c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,598 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_by_id_request( - schedule_definition_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py deleted file mode 100644 index d924a02a47bb..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_05_01_preview.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-05-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py deleted file mode 100644 index 7975dfdc77be..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import DenyAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to get deny - assignments. A deny assignment describes the set of actions on resources that are denied for - Azure Active Directory users. - - :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: - azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py deleted file mode 100644 index 284188d97bca..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json deleted file mode 100644 index 92e1896abe79..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2018-07-01-preview", - "total_api_version_list": ["2018-07-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "deny_assignments": "DenyAssignmentsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 0ebc0b77e131..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import DenyAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to get deny - assignments. A deny assignment describes the set of actions on resources that are denied for - Azure Active Directory users. - - :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: - azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-07-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py deleted file mode 100644 index c302fa6a1cab..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index 9118a306bbaa..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._deny_assignments_operations import DenyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DenyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py deleted file mode 100644 index ff430ddfd414..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py +++ /dev/null @@ -1,608 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._deny_assignments_operations import ( - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DenyAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`deny_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: - """Gets deny assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get deny assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: - """Gets deny assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.DenyAssignment"]: - """Gets all deny assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - - @distributed_trace_async - async def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: - """Get the specified deny assignment. - - :param scope: The scope of the deny assignment. Required. - :type scope: str - :param deny_assignment_id: The ID of the deny assignment to get. Required. - :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - deny_assignment_id=deny_assignment_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DenyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} - - @distributed_trace_async - async def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: - """Gets a deny assignment by ID. - - :param deny_assignment_id: 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. Required. - :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - deny_assignment_id=deny_assignment_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DenyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{denyAssignmentId}"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.DenyAssignment"]: - """Gets deny assignments for a scope. - - :param scope: The scope of the deny assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py deleted file mode 100644 index c01af9a96f46..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import DenyAssignment -from ._models_py3 import DenyAssignmentFilter -from ._models_py3 import DenyAssignmentListResult -from ._models_py3 import DenyAssignmentPermission -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Principal -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DenyAssignment", - "DenyAssignmentFilter", - "DenyAssignmentListResult", - "DenyAssignmentPermission", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Principal", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py deleted file mode 100644 index 0d2f93fa38ae..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,376 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Deny Assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The deny assignment ID. - :vartype id: str - :ivar name: The deny assignment name. - :vartype name: str - :ivar type: The deny assignment type. - :vartype type: str - :ivar deny_assignment_name: The display name of the deny assignment. - :vartype deny_assignment_name: str - :ivar description: The description of the deny assignment. - :vartype description: str - :ivar permissions: An array of permissions that are denied by the deny assignment. - :vartype permissions: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] - :ivar scope: The deny assignment scope. - :vartype scope: str - :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. - Default value is false. - :vartype do_not_apply_to_child_scopes: bool - :ivar principals: Array of principals to which the deny assignment applies. - :vartype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :ivar exclude_principals: Array of principals to which the deny assignment does not apply. - :vartype exclude_principals: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :vartype is_system_protected: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, - "scope": {"key": "properties.scope", "type": "str"}, - "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, - "principals": {"key": "properties.principals", "type": "[Principal]"}, - "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, - "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, - } - - def __init__( - self, - *, - deny_assignment_name: Optional[str] = None, - description: Optional[str] = None, - permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, - scope: Optional[str] = None, - do_not_apply_to_child_scopes: Optional[bool] = None, - principals: Optional[List["_models.Principal"]] = None, - exclude_principals: Optional[List["_models.Principal"]] = None, - is_system_protected: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword deny_assignment_name: The display name of the deny assignment. - :paramtype deny_assignment_name: str - :keyword description: The description of the deny assignment. - :paramtype description: str - :keyword permissions: An array of permissions that are denied by the deny assignment. - :paramtype permissions: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] - :keyword scope: The deny assignment scope. - :paramtype scope: str - :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child - scopes. Default value is false. - :paramtype do_not_apply_to_child_scopes: bool - :keyword principals: Array of principals to which the deny assignment applies. - :paramtype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :keyword exclude_principals: Array of principals to which the deny assignment does not apply. - :paramtype exclude_principals: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :paramtype is_system_protected: bool - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.deny_assignment_name = deny_assignment_name - self.description = description - self.permissions = permissions - self.scope = scope - self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes - self.principals = principals - self.exclude_principals = exclude_principals - self.is_system_protected = is_system_protected - - -class DenyAssignmentFilter(_serialization.Model): - """Deny Assignments filter. - - :ivar deny_assignment_name: Return deny assignment with specified name. - :vartype deny_assignment_name: str - :ivar principal_id: Return all deny assignments where the specified principal is listed in the - principals list of deny assignments. - :vartype principal_id: str - :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is - listed either in the principals list or exclude principals list of deny assignments. - :vartype gdpr_export_principal_id: str - """ - - _attribute_map = { - "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, - } - - def __init__( - self, - *, - deny_assignment_name: Optional[str] = None, - principal_id: Optional[str] = None, - gdpr_export_principal_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword deny_assignment_name: Return deny assignment with specified name. - :paramtype deny_assignment_name: str - :keyword principal_id: Return all deny assignments where the specified principal is listed in - the principals list of deny assignments. - :paramtype principal_id: str - :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is - listed either in the principals list or exclude principals list of deny assignments. - :paramtype gdpr_export_principal_id: str - """ - super().__init__(**kwargs) - self.deny_assignment_name = deny_assignment_name - self.principal_id = principal_id - self.gdpr_export_principal_id = gdpr_export_principal_id - - -class DenyAssignmentListResult(_serialization.Model): - """Deny assignment list operation result. - - :ivar value: Deny assignment list. - :vartype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DenyAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Deny assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DenyAssignmentPermission(_serialization.Model): - """Deny assignment permissions. - - :ivar actions: Actions to which the deny assignment does not grant access. - :vartype actions: list[str] - :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. - :vartype not_actions: list[str] - :ivar data_actions: Data actions to which the deny assignment does not grant access. - :vartype data_actions: list[str] - :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Actions to which the deny assignment does not grant access. - :paramtype actions: list[str] - :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. - :paramtype not_actions: list[str] - :keyword data_actions: Data actions to which the deny assignment does not grant access. - :paramtype data_actions: list[str] - :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Principal(_serialization.Model): - """The name of the entity last modified it. - - :ivar id: The id of the principal made changes. - :vartype id: str - :ivar display_name: The name of the principal made changes. - :vartype display_name: str - :ivar type: Type of principal such as user , group etc. - :vartype type: str - :ivar email: Email of principal. - :vartype email: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - email: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the principal made changes. - :paramtype id: str - :keyword display_name: The name of the principal made changes. - :paramtype display_name: str - :keyword type: Type of principal such as user , group etc. - :paramtype type: str - :keyword email: Email of principal. - :paramtype email: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - self.email = email diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/__init__.py deleted file mode 100644 index 9118a306bbaa..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._deny_assignments_operations import DenyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DenyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py deleted file mode 100644 index 7549851ad47d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py +++ /dev/null @@ -1,788 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, deny_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(deny_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{denyAssignmentId}") - path_format_arguments = { - "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class DenyAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_07_01_preview.AuthorizationManagementClient`'s - :attr:`deny_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: - """Gets deny assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get deny assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: - """Gets deny assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments" - } - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.DenyAssignment"]: - """Gets all deny assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} - - @distributed_trace - def get(self, scope: str, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: - """Get the specified deny assignment. - - :param scope: The scope of the deny assignment. Required. - :type scope: str - :param deny_assignment_id: The ID of the deny assignment to get. Required. - :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - deny_assignment_id=deny_assignment_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DenyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} - - @distributed_trace - def get_by_id(self, deny_assignment_id: str, **kwargs: Any) -> _models.DenyAssignment: - """Gets a deny assignment by ID. - - :param deny_assignment_id: 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. Required. - :type deny_assignment_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DenyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - deny_assignment_id=deny_assignment_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("DenyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{denyAssignmentId}"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.DenyAssignment"]: - """Gets deny assignments for a scope. - - :param scope: The scope of the deny assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-07-01-preview") - ) - cls: ClsType[_models.DenyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/denyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py deleted file mode 100644 index e62641a6e5bf..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py deleted file mode 100644 index 863895fcb33f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json deleted file mode 100644 index a6c48bf89a75..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2018-09-01-preview", - "total_api_version_list": ["2018-09-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "role_assignments": "RoleAssignmentsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index a9c7a08d8f5e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2018-09-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py deleted file mode 100644 index 8841ae1b0d47..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2018-09-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/__init__.py deleted file mode 100644 index 0d22b3a23897..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py deleted file mode 100644 index 1b10589d163f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py +++ /dev/null @@ -1,986 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignments_operations import ( - build_create_by_id_request, - build_create_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_09_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace_async - async def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - async def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace_async - async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py deleted file mode 100644 index ca8ae3cbd5a1..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult - -from ._authorization_management_client_enums import PrincipalType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "PrincipalType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index 4519b342017f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py deleted file mode 100644 index ab4f4604c7cd..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py +++ /dev/null @@ -1,301 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class RoleAssignment(_serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - can_delegate: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.can_delegate = can_delegate - - -class RoleAssignmentCreateParameters(_serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :ivar role_definition_id: The role definition ID used in the role assignment. Required. - :vartype role_definition_id: str - :ivar principal_id: 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. Required. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :ivar can_delegate: The delegation flag used for creating a role assignment. - :vartype can_delegate: bool - """ - - _validation = { - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - } - - _attribute_map = { - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - } - - def __init__( - self, - *, - role_definition_id: str, - principal_id: str, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - can_delegate: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID used in the role assignment. Required. - :paramtype role_definition_id: str - :keyword principal_id: 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. Required. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :keyword can_delegate: The delegation flag used for creating a role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.can_delegate = can_delegate - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "can_delegate": {"key": "canDelegate", "type": "bool"}, - } - - def __init__( - self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.can_delegate = can_delegate - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/__init__.py deleted file mode 100644 index 0d22b3a23897..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py deleted file mode 100644 index 36aeaa1c57e6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1266 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2018_09_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def delete(self, scope: str, role_assignment_name: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def get(self, scope: str, role_assignment_name: str, **kwargs: Any) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def delete_by_id(self, role_id: str, **kwargs: Any) -> Optional[_models.RoleAssignment]: - """Deletes a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2018-09-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py deleted file mode 100644 index deb75cdee38b..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentMetricsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations - :vartype role_assignment_metrics: - azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py deleted file mode 100644 index e4a18fcf0fa3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json deleted file mode 100644 index 935618b6c875..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2019-08-01-preview", - "total_api_version_list": ["2019-08-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "role_assignment_metrics": "RoleAssignmentMetricsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index e68025f85285..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentMetricsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations - :vartype role_assignment_metrics: - azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py deleted file mode 100644 index 66d50b07bc2a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2019-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index b9b816cbd62e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignment_metrics_operations import RoleAssignmentMetricsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentMetricsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py deleted file mode 100644 index 8fde64168d76..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py +++ /dev/null @@ -1,110 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_metrics_operations import build_get_metrics_for_subscription_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentMetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2019_08_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: - """Get role assignment usage metrics for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentMetricsResult or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") - ) - cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) - - request = build_get_metrics_for_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_metrics_for_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_metrics_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py deleted file mode 100644 index 9af825dd8848..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import RoleAssignmentMetricsResult -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "RoleAssignmentMetricsResult", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py deleted file mode 100644 index 0d8478057cff..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,147 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class RoleAssignmentMetricsResult(_serialization.Model): - """Role Assignment Metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar subscription_id: The subscription ID. - :vartype subscription_id: str - :ivar role_assignments_limit: The role assignment limit. - :vartype role_assignments_limit: int - :ivar role_assignments_current_count: The number of current role assignments. - :vartype role_assignments_current_count: int - :ivar role_assignments_remaining_count: The number of remaining role assignments available. - :vartype role_assignments_remaining_count: int - """ - - _validation = { - "subscription_id": {"readonly": True}, - "role_assignments_limit": {"readonly": True}, - "role_assignments_current_count": {"readonly": True}, - "role_assignments_remaining_count": {"readonly": True}, - } - - _attribute_map = { - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "role_assignments_limit": {"key": "roleAssignmentsLimit", "type": "int"}, - "role_assignments_current_count": {"key": "roleAssignmentsCurrentCount", "type": "int"}, - "role_assignments_remaining_count": {"key": "roleAssignmentsRemainingCount", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.subscription_id = None - self.role_assignments_limit = None - self.role_assignments_current_count = None - self.role_assignments_remaining_count = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/__init__.py deleted file mode 100644 index b9b816cbd62e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignment_metrics_operations import RoleAssignmentMetricsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentMetricsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py deleted file mode 100644 index 41ab3da09a46..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py +++ /dev/null @@ -1,139 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_metrics_for_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentMetricsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2019_08_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_metrics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get_metrics_for_subscription(self, **kwargs: Any) -> _models.RoleAssignmentMetricsResult: - """Get role assignment usage metrics for a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentMetricsResult or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2019_08_01_preview.models.RoleAssignmentMetricsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-08-01-preview") - ) - cls: ClsType[_models.RoleAssignmentMetricsResult] = kwargs.pop("cls", None) - - request = build_get_metrics_for_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_metrics_for_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentMetricsResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_metrics_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py deleted file mode 100644 index 3cdc34f3a2c0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2020_04_01_preview.operations.RoleAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py deleted file mode 100644 index 80f427785333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-04-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json deleted file mode 100644 index 6ff2f6e79701..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2020-04-01-preview", - "total_api_version_list": ["2020-04-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "role_assignments": "RoleAssignmentsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index d2be59ccf08a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py deleted file mode 100644 index 741cb552215b..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-04-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/__init__.py deleted file mode 100644 index 0d22b3a23897..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py deleted file mode 100644 index 83d7ed40c526..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1019 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignments_operations import ( - build_create_by_id_request, - build_create_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_04_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace_async - async def delete( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def delete_by_id( - self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - async def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace_async - async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list( - self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py deleted file mode 100644 index ca8ae3cbd5a1..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult - -from ._authorization_management_client_enums import PrincipalType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "PrincipalType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index 4519b342017f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py deleted file mode 100644 index 805b0304cbb9..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py +++ /dev/null @@ -1,404 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - can_delegate: Optional[bool] = None, - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - updated_on: Optional[datetime.datetime] = None, - created_by: Optional[str] = None, - updated_by: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: Time it was created. - :paramtype created_on: ~datetime.datetime - :keyword updated_on: Time it was updated. - :paramtype updated_on: ~datetime.datetime - :keyword created_by: Id of the user who created the assignment. - :paramtype created_by: str - :keyword updated_by: Id of the user who updated the assignment. - :paramtype updated_by: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.can_delegate = can_delegate - self.description = description - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.updated_on = updated_on - self.created_by = created_by - self.updated_by = updated_by - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentCreateParameters(_serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :ivar role_definition_id: The role definition ID used in the role assignment. Required. - :vartype role_definition_id: str - :ivar principal_id: 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. Required. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :ivar can_delegate: The delegation flag used for creating a role assignment. - :vartype can_delegate: bool - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - } - - _attribute_map = { - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - role_definition_id: str, - principal_id: str, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - can_delegate: Optional[bool] = None, - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID used in the role assignment. Required. - :paramtype role_definition_id: str - :keyword principal_id: 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. Required. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", and "ForeignGroup". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :keyword can_delegate: The delegation flag used for creating a role assignment. - :paramtype can_delegate: bool - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.can_delegate = can_delegate - self.description = description - self.condition = condition - self.condition_version = condition_version - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - :ivar can_delegate: The Delegation flag for the role assignment. - :vartype can_delegate: bool - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "can_delegate": {"key": "canDelegate", "type": "bool"}, - } - - def __init__( - self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - :keyword can_delegate: The Delegation flag for the role assignment. - :paramtype can_delegate: bool - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.can_delegate = can_delegate - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/__init__.py deleted file mode 100644 index 0d22b3a23897..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py deleted file mode 100644 index 709edb7a0bea..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1329 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request( - subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request( - scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_04_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List role assignments for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get role assignments for. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List role assignments for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def delete( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment. - - :param scope: The scope of the role assignment to delete. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to delete. Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Create a role assignment. - - :param scope: The scope of the role assignment to create. The scope can be any REST resource - instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, - and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' - for a resource. Required. - :type scope: str - :param role_assignment_name: A GUID for the role assignment to create. The name must be unique - and different for each role assignment. Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def get( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get the specified role assignment. - - :param scope: The scope of the role assignment. Required. - :type scope: str - :param role_assignment_name: The name of the role assignment to get. Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def delete_by_id( - self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment. - - :param role_id: The ID of the role assignment to delete. Required. - :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_id=role_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleId}"} - - @overload - def create_by_id( - self, - role_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Creates a role assignment by ID. - - :param role_id: The ID of the role assignment to create. Required. - :type role_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_id=role_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: - """Gets a role assignment by ID. - - :param role_id: The ID of the role assignment to get. Required. - :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} - - @distributed_trace - def list( - self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets all role assignments for the subscription. - - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """Gets role assignments for a scope. - - :param scope: The scope of the role assignments. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py deleted file mode 100644 index 639e414d454d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - EligibleChildResourcesOperations, - RoleAssignmentScheduleInstancesOperations, - RoleAssignmentScheduleRequestsOperations, - RoleAssignmentSchedulesOperations, - RoleEligibilityScheduleInstancesOperations, - RoleEligibilityScheduleRequestsOperations, - RoleEligibilitySchedulesOperations, - RoleManagementPoliciesOperations, - RoleManagementPolicyAssignmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: - azure.mgmt.authorization.v2020_10_01.operations.EligibleChildResourcesOperations - :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: - azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentSchedulesOperations - :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: - azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentScheduleInstancesOperations - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: - azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations - operations - :vartype role_eligibility_schedule_instances: - azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilityScheduleInstancesOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilityScheduleRequestsOperations - :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: - azure.mgmt.authorization.v2020_10_01.operations.RoleManagementPoliciesOperations - :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: - azure.mgmt.authorization.v2020_10_01.operations.RoleManagementPolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py deleted file mode 100644 index aea735ace4db..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json deleted file mode 100644 index 29397fd61b07..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "chosen_version": "2020-10-01", - "total_api_version_list": ["2020-10-01"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "eligible_child_resources": "EligibleChildResourcesOperations", - "role_assignment_schedules": "RoleAssignmentSchedulesOperations", - "role_assignment_schedule_instances": "RoleAssignmentScheduleInstancesOperations", - "role_assignment_schedule_requests": "RoleAssignmentScheduleRequestsOperations", - "role_eligibility_schedules": "RoleEligibilitySchedulesOperations", - "role_eligibility_schedule_instances": "RoleEligibilityScheduleInstancesOperations", - "role_eligibility_schedule_requests": "RoleEligibilityScheduleRequestsOperations", - "role_management_policies": "RoleManagementPoliciesOperations", - "role_management_policy_assignments": "RoleManagementPolicyAssignmentsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py deleted file mode 100644 index 78cdb17387c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - EligibleChildResourcesOperations, - RoleAssignmentScheduleInstancesOperations, - RoleAssignmentScheduleRequestsOperations, - RoleAssignmentSchedulesOperations, - RoleEligibilityScheduleInstancesOperations, - RoleEligibilityScheduleRequestsOperations, - RoleEligibilitySchedulesOperations, - RoleManagementPoliciesOperations, - RoleManagementPolicyAssignmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: - azure.mgmt.authorization.v2020_10_01.aio.operations.EligibleChildResourcesOperations - :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentSchedulesOperations - :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleInstancesOperations - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations - operations - :vartype role_eligibility_schedule_instances: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleInstancesOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleRequestsOperations - :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPoliciesOperations - :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: - azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py deleted file mode 100644 index 28344f73847e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py deleted file mode 100644 index 31a4ba4b86ec..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._eligible_child_resources_operations import EligibleChildResourcesOperations -from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations -from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations -from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations -from ._role_management_policies_operations import RoleManagementPoliciesOperations -from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "EligibleChildResourcesOperations", - "RoleAssignmentSchedulesOperations", - "RoleAssignmentScheduleInstancesOperations", - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilitySchedulesOperations", - "RoleEligibilityScheduleInstancesOperations", - "RoleEligibilityScheduleRequestsOperations", - "RoleManagementPoliciesOperations", - "RoleManagementPolicyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py deleted file mode 100644 index 1f18506a6b36..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ApprovalSettings -from ._models_py3 import ApprovalStage -from ._models_py3 import CloudErrorBody -from ._models_py3 import EligibleChildResource -from ._models_py3 import EligibleChildResourcesListResult -from ._models_py3 import ExpandedProperties -from ._models_py3 import ExpandedPropertiesPrincipal -from ._models_py3 import ExpandedPropertiesRoleDefinition -from ._models_py3 import ExpandedPropertiesScope -from ._models_py3 import Permission -from ._models_py3 import PolicyAssignmentProperties -from ._models_py3 import PolicyAssignmentPropertiesPolicy -from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition -from ._models_py3 import PolicyAssignmentPropertiesScope -from ._models_py3 import PolicyProperties -from ._models_py3 import PolicyPropertiesScope -from ._models_py3 import Principal -from ._models_py3 import RoleAssignmentSchedule -from ._models_py3 import RoleAssignmentScheduleFilter -from ._models_py3 import RoleAssignmentScheduleInstance -from ._models_py3 import RoleAssignmentScheduleInstanceFilter -from ._models_py3 import RoleAssignmentScheduleInstanceListResult -from ._models_py3 import RoleAssignmentScheduleListResult -from ._models_py3 import RoleAssignmentScheduleRequest -from ._models_py3 import RoleAssignmentScheduleRequestFilter -from ._models_py3 import RoleAssignmentScheduleRequestListResult -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo -from ._models_py3 import RoleEligibilitySchedule -from ._models_py3 import RoleEligibilityScheduleFilter -from ._models_py3 import RoleEligibilityScheduleInstance -from ._models_py3 import RoleEligibilityScheduleInstanceFilter -from ._models_py3 import RoleEligibilityScheduleInstanceListResult -from ._models_py3 import RoleEligibilityScheduleListResult -from ._models_py3 import RoleEligibilityScheduleRequest -from ._models_py3 import RoleEligibilityScheduleRequestFilter -from ._models_py3 import RoleEligibilityScheduleRequestListResult -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo -from ._models_py3 import RoleManagementPolicy -from ._models_py3 import RoleManagementPolicyApprovalRule -from ._models_py3 import RoleManagementPolicyAssignment -from ._models_py3 import RoleManagementPolicyAssignmentListResult -from ._models_py3 import RoleManagementPolicyAuthenticationContextRule -from ._models_py3 import RoleManagementPolicyEnablementRule -from ._models_py3 import RoleManagementPolicyExpirationRule -from ._models_py3 import RoleManagementPolicyListResult -from ._models_py3 import RoleManagementPolicyNotificationRule -from ._models_py3 import RoleManagementPolicyRule -from ._models_py3 import RoleManagementPolicyRuleTarget -from ._models_py3 import UserSet - -from ._authorization_management_client_enums import ApprovalMode -from ._authorization_management_client_enums import AssignmentType -from ._authorization_management_client_enums import EnablementRules -from ._authorization_management_client_enums import MemberType -from ._authorization_management_client_enums import NotificationDeliveryMechanism -from ._authorization_management_client_enums import NotificationLevel -from ._authorization_management_client_enums import PrincipalType -from ._authorization_management_client_enums import RecipientType -from ._authorization_management_client_enums import RequestType -from ._authorization_management_client_enums import RoleManagementPolicyRuleType -from ._authorization_management_client_enums import Status -from ._authorization_management_client_enums import Type -from ._authorization_management_client_enums import UserType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApprovalSettings", - "ApprovalStage", - "CloudErrorBody", - "EligibleChildResource", - "EligibleChildResourcesListResult", - "ExpandedProperties", - "ExpandedPropertiesPrincipal", - "ExpandedPropertiesRoleDefinition", - "ExpandedPropertiesScope", - "Permission", - "PolicyAssignmentProperties", - "PolicyAssignmentPropertiesPolicy", - "PolicyAssignmentPropertiesRoleDefinition", - "PolicyAssignmentPropertiesScope", - "PolicyProperties", - "PolicyPropertiesScope", - "Principal", - "RoleAssignmentSchedule", - "RoleAssignmentScheduleFilter", - "RoleAssignmentScheduleInstance", - "RoleAssignmentScheduleInstanceFilter", - "RoleAssignmentScheduleInstanceListResult", - "RoleAssignmentScheduleListResult", - "RoleAssignmentScheduleRequest", - "RoleAssignmentScheduleRequestFilter", - "RoleAssignmentScheduleRequestListResult", - "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", - "RoleAssignmentScheduleRequestPropertiesTicketInfo", - "RoleEligibilitySchedule", - "RoleEligibilityScheduleFilter", - "RoleEligibilityScheduleInstance", - "RoleEligibilityScheduleInstanceFilter", - "RoleEligibilityScheduleInstanceListResult", - "RoleEligibilityScheduleListResult", - "RoleEligibilityScheduleRequest", - "RoleEligibilityScheduleRequestFilter", - "RoleEligibilityScheduleRequestListResult", - "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", - "RoleEligibilityScheduleRequestPropertiesTicketInfo", - "RoleManagementPolicy", - "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAssignment", - "RoleManagementPolicyAssignmentListResult", - "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyListResult", - "RoleManagementPolicyNotificationRule", - "RoleManagementPolicyRule", - "RoleManagementPolicyRuleTarget", - "UserSet", - "ApprovalMode", - "AssignmentType", - "EnablementRules", - "MemberType", - "NotificationDeliveryMechanism", - "NotificationLevel", - "PrincipalType", - "RecipientType", - "RequestType", - "RoleManagementPolicyRuleType", - "Status", - "Type", - "UserType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py deleted file mode 100644 index b7fe646a9920..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,140 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - SINGLE_STAGE = "SingleStage" - SERIAL = "Serial" - PARALLEL = "Parallel" - NO_APPROVAL = "NoApproval" - - -class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Assignment type of the role assignment schedule.""" - - ACTIVATED = "Activated" - ASSIGNED = "Assigned" - - -class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of enablement rule.""" - - MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" - JUSTIFICATION = "Justification" - TICKETING = "Ticketing" - - -class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Membership type of the role assignment schedule.""" - - INHERITED = "Inherited" - DIRECT = "Direct" - GROUP = "Group" - - -class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of notification.""" - - EMAIL = "Email" - - -class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The notification level.""" - - NONE = "None" - CRITICAL = "Critical" - ALL = "All" - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" - DEVICE = "Device" - - -class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recipient type.""" - - REQUESTOR = "Requestor" - APPROVER = "Approver" - ADMIN = "Admin" - - -class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" - - ADMIN_ASSIGN = "AdminAssign" - ADMIN_REMOVE = "AdminRemove" - ADMIN_UPDATE = "AdminUpdate" - ADMIN_EXTEND = "AdminExtend" - ADMIN_RENEW = "AdminRenew" - SELF_ACTIVATE = "SelfActivate" - SELF_DEACTIVATE = "SelfDeactivate" - SELF_EXTEND = "SelfExtend" - SELF_RENEW = "SelfRenew" - - -class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" - ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" - ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" - ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" - ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" - - -class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the role assignment schedule.""" - - ACCEPTED = "Accepted" - PENDING_EVALUATION = "PendingEvaluation" - GRANTED = "Granted" - DENIED = "Denied" - PENDING_PROVISIONING = "PendingProvisioning" - PROVISIONED = "Provisioned" - PENDING_REVOCATION = "PendingRevocation" - REVOKED = "Revoked" - CANCELED = "Canceled" - FAILED = "Failed" - PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" - PENDING_APPROVAL = "PendingApproval" - FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" - PENDING_ADMIN_DECISION = "PendingAdminDecision" - ADMIN_APPROVED = "AdminApproved" - ADMIN_DENIED = "AdminDenied" - TIMED_OUT = "TimedOut" - PROVISIONING_STARTED = "ProvisioningStarted" - INVALID = "Invalid" - PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" - SCHEDULE_CREATED = "ScheduleCreated" - PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of the role assignment schedule expiration.""" - - AFTER_DURATION = "AfterDuration" - AFTER_DATE_TIME = "AfterDateTime" - NO_EXPIRATION = "NoExpiration" - - -class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of user.""" - - USER = "User" - GROUP = "Group" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py deleted file mode 100644 index bdd139feaa79..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py +++ /dev/null @@ -1,3126 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ApprovalSettings(_serialization.Model): - """The approval settings. - - :ivar is_approval_required: Determines whether approval is required or not. - :vartype is_approval_required: bool - :ivar is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :vartype is_approval_required_for_extension: bool - :ivar is_requestor_justification_required: Determine whether requestor justification is - required. - :vartype is_requestor_justification_required: bool - :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", - and "NoApproval". - :vartype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01.models.ApprovalMode - :ivar approval_stages: The approval stages of the request. - :vartype approval_stages: list[~azure.mgmt.authorization.v2020_10_01.models.ApprovalStage] - """ - - _attribute_map = { - "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, - "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, - "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, - "approval_mode": {"key": "approvalMode", "type": "str"}, - "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, - } - - def __init__( - self, - *, - is_approval_required: Optional[bool] = None, - is_approval_required_for_extension: Optional[bool] = None, - is_requestor_justification_required: Optional[bool] = None, - approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, - approval_stages: Optional[List["_models.ApprovalStage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_approval_required: Determines whether approval is required or not. - :paramtype is_approval_required: bool - :keyword is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :paramtype is_approval_required_for_extension: bool - :keyword is_requestor_justification_required: Determine whether requestor justification is - required. - :paramtype is_requestor_justification_required: bool - :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", - "Parallel", and "NoApproval". - :paramtype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01.models.ApprovalMode - :keyword approval_stages: The approval stages of the request. - :paramtype approval_stages: list[~azure.mgmt.authorization.v2020_10_01.models.ApprovalStage] - """ - super().__init__(**kwargs) - self.is_approval_required = is_approval_required - self.is_approval_required_for_extension = is_approval_required_for_extension - self.is_requestor_justification_required = is_requestor_justification_required - self.approval_mode = approval_mode - self.approval_stages = approval_stages - - -class ApprovalStage(_serialization.Model): - """The approval stage. - - :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :vartype approval_stage_time_out_in_days: int - :ivar is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :vartype is_approver_justification_required: bool - :ivar escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :vartype escalation_time_in_minutes: int - :ivar primary_approvers: The primary approver of the request. - :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] - :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. - :vartype is_escalation_enabled: bool - :ivar escalation_approvers: The escalation approver of the request. - :vartype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] - """ - - _attribute_map = { - "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, - "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, - "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, - "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, - "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, - "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, - } - - def __init__( - self, - *, - approval_stage_time_out_in_days: Optional[int] = None, - is_approver_justification_required: Optional[bool] = None, - escalation_time_in_minutes: Optional[int] = None, - primary_approvers: Optional[List["_models.UserSet"]] = None, - is_escalation_enabled: Optional[bool] = None, - escalation_approvers: Optional[List["_models.UserSet"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :paramtype approval_stage_time_out_in_days: int - :keyword is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :paramtype is_approver_justification_required: bool - :keyword escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :paramtype escalation_time_in_minutes: int - :keyword primary_approvers: The primary approver of the request. - :paramtype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] - :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. - :paramtype is_escalation_enabled: bool - :keyword escalation_approvers: The escalation approver of the request. - :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] - """ - super().__init__(**kwargs) - self.approval_stage_time_out_in_days = approval_stage_time_out_in_days - self.is_approver_justification_required = is_approver_justification_required - self.escalation_time_in_minutes = escalation_time_in_minutes - self.primary_approvers = primary_approvers - self.is_escalation_enabled = is_escalation_enabled - self.escalation_approvers = escalation_approvers - - -class CloudErrorBody(_serialization.Model): - """An error response from the service. - - :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :vartype code: str - :ivar message: A message describing the error, intended to be suitable for display in a user - interface. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :paramtype code: str - :keyword message: A message describing the error, intended to be suitable for display in a user - interface. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EligibleChildResource(_serialization.Model): - """Eligible child resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource scope Id. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class EligibleChildResourcesListResult(_serialization.Model): - """Eligible child resources list operation result. - - :ivar value: Eligible child resource list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[EligibleChildResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.EligibleChildResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Eligible child resource list. - :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ExpandedProperties(_serialization.Model): - """ExpandedProperties. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesScope - :ivar role_definition: Details of role definition. - :vartype role_definition: - ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesRoleDefinition - :ivar principal: Details of the principal. - :vartype principal: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesPrincipal - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, - "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, - "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, - } - - def __init__( - self, - *, - scope: Optional["_models.ExpandedPropertiesScope"] = None, - role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, - principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: Details of the resource scope. - :paramtype scope: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesScope - :keyword role_definition: Details of role definition. - :paramtype role_definition: - ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesRoleDefinition - :keyword principal: Details of the principal. - :paramtype principal: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesPrincipal - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition = role_definition - self.principal = principal - - -class ExpandedPropertiesPrincipal(_serialization.Model): - """Details of the principal. - - :ivar id: Id of the principal. - :vartype id: str - :ivar display_name: Display name of the principal. - :vartype display_name: str - :ivar email: Email id of the principal. - :vartype email: str - :ivar type: Type of the principal. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "email": {"key": "email", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - email: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the principal. - :paramtype id: str - :keyword display_name: Display name of the principal. - :paramtype display_name: str - :keyword email: Email id of the principal. - :paramtype email: str - :keyword type: Type of the principal. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.email = email - self.type = type - - -class ExpandedPropertiesRoleDefinition(_serialization.Model): - """Details of role definition. - - :ivar id: Id of the role definition. - :vartype id: str - :ivar display_name: Display name of the role definition. - :vartype display_name: str - :ivar type: Type of the role definition. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the role definition. - :paramtype id: str - :keyword display_name: Display name of the role definition. - :paramtype display_name: str - :keyword type: Type of the role definition. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class ExpandedPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class PolicyAssignmentProperties(_serialization.Model): - """Expanded info of resource scope, role definition and policy. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesScope - :ivar role_definition: Details of role definition. - :vartype role_definition: - ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesRoleDefinition - :ivar policy: Details of the policy. - :vartype policy: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesPolicy - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "PolicyAssignmentPropertiesScope"}, - "role_definition": {"key": "roleDefinition", "type": "PolicyAssignmentPropertiesRoleDefinition"}, - "policy": {"key": "policy", "type": "PolicyAssignmentPropertiesPolicy"}, - } - - def __init__( - self, - *, - scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, - role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, - policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: Details of the resource scope. - :paramtype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesScope - :keyword role_definition: Details of role definition. - :paramtype role_definition: - ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesRoleDefinition - :keyword policy: Details of the policy. - :paramtype policy: - ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesPolicy - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition = role_definition - self.policy = policy - - -class PolicyAssignmentPropertiesPolicy(_serialization.Model): - """Details of the policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the policy. - :vartype id: str - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01.models.Principal - :ivar last_modified_date_time: The last modified date time. - :vartype last_modified_date_time: ~datetime.datetime - """ - - _validation = { - "last_modified_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "Principal"}, - "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - last_modified_date_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the policy. - :paramtype id: str - :keyword last_modified_date_time: The last modified date time. - :paramtype last_modified_date_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.id = id - self.last_modified_by = None - self.last_modified_date_time = last_modified_date_time - - -class PolicyAssignmentPropertiesRoleDefinition(_serialization.Model): - """Details of role definition. - - :ivar id: Id of the role definition. - :vartype id: str - :ivar display_name: Display name of the role definition. - :vartype display_name: str - :ivar type: Type of the role definition. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the role definition. - :paramtype id: str - :keyword display_name: Display name of the role definition. - :paramtype display_name: str - :keyword type: Type of the role definition. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class PolicyAssignmentPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class PolicyProperties(_serialization.Model): - """Expanded info of resource scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyPropertiesScope - """ - - _validation = { - "scope": {"readonly": True}, - } - - _attribute_map = { - "scope": {"key": "scope", "type": "PolicyPropertiesScope"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.scope = None - - -class PolicyPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class Principal(_serialization.Model): - """The name of the entity last modified it. - - :ivar id: The id of the principal made changes. - :vartype id: str - :ivar display_name: The name of the principal made changes. - :vartype display_name: str - :ivar type: Type of principal such as user , group etc. - :vartype type: str - :ivar email: Email of principal. - :vartype email: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - email: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the principal made changes. - :paramtype id: str - :keyword display_name: The name of the principal made changes. - :paramtype display_name: str - :keyword type: Type of principal such as user , group etc. - :paramtype type: str - :keyword email: Email of principal. - :paramtype email: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - self.email = email - - -class RoleAssignmentSchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignment schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule Id. - :vartype id: str - :ivar name: The role assignment schedule name. - :vartype name: str - :ivar type: The role assignment schedule type. - :vartype type: str - :ivar scope: The role assignment schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :vartype role_assignment_schedule_request_id: str - :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated - this roleAssignmentSchedule. - :vartype linked_role_eligibility_schedule_id: str - :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType - :ivar member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :ivar status: The status of the role assignment schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar start_date_time: Start DateTime when role assignment schedule. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: End DateTime when role assignment schedule. - :vartype end_date_time: ~datetime.datetime - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: DateTime when role assignment schedule was modified. - :vartype updated_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_assignment_schedule_request_id": {"key": "properties.roleAssignmentScheduleRequestId", "type": "str"}, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "assignment_type": {"key": "properties.assignmentType", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_assignment_schedule_request_id: Optional[str] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - updated_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :paramtype role_assignment_schedule_request_id: str - :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to - activated this roleAssignmentSchedule. - :paramtype linked_role_eligibility_schedule_id: str - :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType - :keyword member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :keyword status: The status of the role assignment schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :keyword start_date_time: Start DateTime when role assignment schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: End DateTime when role assignment schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role assignment schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword updated_on: DateTime when role assignment schedule was modified. - :paramtype updated_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_assignment_schedule_request_id = role_assignment_schedule_request_id - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.assignment_type = assignment_type - self.member_type = member_type - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.updated_on = updated_on - self.expanded_properties = expanded_properties - - -class RoleAssignmentScheduleFilter(_serialization.Model): - """Role assignment schedule filter. - - :ivar principal_id: Returns role assignment schedule of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment schedule of the specific role definition. - :vartype role_definition_id: str - :ivar status: Returns role assignment schedule instances of the specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment schedule of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment schedule of the specific role definition. - :paramtype role_definition_id: str - :keyword status: Returns role assignment schedule instances of the specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - - -class RoleAssignmentScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Information about current or upcoming role assignment schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule instance ID. - :vartype id: str - :ivar name: The role assignment schedule instance name. - :vartype name: str - :ivar type: The role assignment schedule instance type. - :vartype type: str - :ivar scope: The role assignment schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar role_assignment_schedule_id: Id of the master role assignment schedule. - :vartype role_assignment_schedule_id: str - :ivar origin_role_assignment_id: Role Assignment Id in external system. - :vartype origin_role_assignment_id: str - :ivar status: The status of the role assignment schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar start_date_time: The startDateTime of the role assignment schedule instance. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The endDateTime of the role assignment schedule instance. - :vartype end_date_time: ~datetime.datetime - :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :vartype linked_role_eligibility_schedule_id: str - :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to - this roleAssignmentScheduleInstance. - :vartype linked_role_eligibility_schedule_instance_id: str - :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType - :ivar member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule was created. - :vartype created_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_assignment_schedule_id": {"key": "properties.roleAssignmentScheduleId", "type": "str"}, - "origin_role_assignment_id": {"key": "properties.originRoleAssignmentId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "linked_role_eligibility_schedule_instance_id": { - "key": "properties.linkedRoleEligibilityScheduleInstanceId", - "type": "str", - }, - "assignment_type": {"key": "properties.assignmentType", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_assignment_schedule_id: Optional[str] = None, - origin_role_assignment_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - linked_role_eligibility_schedule_instance_id: Optional[str] = None, - assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :keyword role_assignment_schedule_id: Id of the master role assignment schedule. - :paramtype role_assignment_schedule_id: str - :keyword origin_role_assignment_id: Role Assignment Id in external system. - :paramtype origin_role_assignment_id: str - :keyword status: The status of the role assignment schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :keyword start_date_time: The startDateTime of the role assignment schedule instance. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The endDateTime of the role assignment schedule instance. - :paramtype end_date_time: ~datetime.datetime - :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :paramtype linked_role_eligibility_schedule_id: str - :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :paramtype linked_role_eligibility_schedule_instance_id: str - :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType - :keyword member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role assignment schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_assignment_schedule_id = role_assignment_schedule_id - self.origin_role_assignment_id = origin_role_assignment_id - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id - self.assignment_type = assignment_type - self.member_type = member_type - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.expanded_properties = expanded_properties - - -class RoleAssignmentScheduleInstanceFilter(_serialization.Model): - """Role assignment schedule instance filter. - - :ivar principal_id: Returns role assignment schedule instances of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :vartype role_definition_id: str - :ivar status: Returns role assignment schedule instances of the specific status. - :vartype status: str - :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :vartype role_assignment_schedule_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "role_assignment_schedule_id": {"key": "roleAssignmentScheduleId", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - role_assignment_schedule_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment schedule instances of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :paramtype role_definition_id: str - :keyword status: Returns role assignment schedule instances of the specific status. - :paramtype status: str - :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :paramtype role_assignment_schedule_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - self.role_assignment_schedule_id = role_assignment_schedule_id - - -class RoleAssignmentScheduleInstanceListResult(_serialization.Model): - """Role assignment schedule instance list operation result. - - :ivar value: Role assignment schedule instance list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentScheduleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleListResult(_serialization.Model): - """Role assignment schedule list operation result. - - :ivar value: Role assignment schedule list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentSchedule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentSchedule"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule list. - :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignment schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule request ID. - :vartype id: str - :ivar name: The role assignment schedule request name. - :vartype name: str - :ivar type: The role assignment schedule request type. - :vartype type: str - :ivar scope: The role assignment schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType - :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar approval_id: The approvalId of the role assignment schedule request. - :vartype approval_id: str - :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role - assignment schedule id being updated. - :vartype target_role_assignment_schedule_id: str - :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :vartype target_role_assignment_schedule_instance_id: str - :ivar schedule_info: Schedule info of the role assignment schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :vartype linked_role_eligibility_schedule_id: str - :ivar justification: Justification for the role assignment. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role assignment. - :vartype ticket_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, - "target_role_assignment_schedule_instance_id": { - "key": "properties.targetRoleAssignmentScheduleInstanceId", - "type": "str", - }, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - }, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - target_role_assignment_schedule_id: Optional[str] = None, - target_role_assignment_schedule_instance_id: Optional[str] = None, - schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType - :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :paramtype target_role_assignment_schedule_id: str - :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :paramtype target_role_assignment_schedule_instance_id: str - :keyword schedule_info: Schedule info of the role assignment schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :paramtype linked_role_eligibility_schedule_id: str - :keyword justification: Justification for the role assignment. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role assignment. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.target_role_assignment_schedule_id = target_role_assignment_schedule_id - self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id - self.schedule_info = schedule_info - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleAssignmentScheduleRequestFilter(_serialization.Model): - """Role assignment schedule request filter. - - :ivar principal_id: Returns role assignment requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role assignment requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role assignment requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role assignment requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role assignment requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleAssignmentScheduleRequestListResult(_serialization.Model): - """Role assignment schedule request list operation result. - - :ivar value: Role assignment schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role assignment schedule. - - :ivar start_date_time: Start DateTime of the role assignment schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role assignment schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role assignment schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role assignment schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role assignment schedule. - - :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", - "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type - :ivar end_date_time: End DateTime of the role assignment schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role assignment schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role assignment schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type - :keyword end_date_time: End DateTime of the role assignment schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role assignment schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role assignment. - - :ivar ticket_number: Ticket number for the role assignment. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role assignment. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role assignment. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role assignment. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system - - -class RoleEligibilitySchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role eligibility schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule Id. - :vartype id: str - :ivar name: The role eligibility schedule name. - :vartype name: str - :ivar type: The role eligibility schedule type. - :vartype type: str - :ivar scope: The role eligibility schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :vartype role_eligibility_schedule_request_id: str - :ivar member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :ivar status: The status of the role eligibility schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar start_date_time: Start DateTime when role eligibility schedule. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: End DateTime when role eligibility schedule. - :vartype end_date_time: ~datetime.datetime - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: DateTime when role eligibility schedule was modified. - :vartype updated_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_eligibility_schedule_request_id": {"key": "properties.roleEligibilityScheduleRequestId", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_eligibility_schedule_request_id: Optional[str] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - updated_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role eligibility schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :paramtype role_eligibility_schedule_request_id: str - :keyword member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :keyword status: The status of the role eligibility schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :keyword start_date_time: Start DateTime when role eligibility schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: End DateTime when role eligibility schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role eligibility schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword updated_on: DateTime when role eligibility schedule was modified. - :paramtype updated_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id - self.member_type = member_type - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.updated_on = updated_on - self.expanded_properties = expanded_properties - - -class RoleEligibilityScheduleFilter(_serialization.Model): - """Role eligibility schedule filter. - - :ivar principal_id: Returns role eligibility schedule of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. - :vartype role_definition_id: str - :ivar status: Returns role eligibility schedule of the specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility schedule of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. - :paramtype role_definition_id: str - :keyword status: Returns role eligibility schedule of the specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - - -class RoleEligibilityScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Information about current or upcoming role eligibility schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule instance ID. - :vartype id: str - :ivar name: The role eligibility schedule instance name. - :vartype name: str - :ivar type: The role eligibility schedule instance type. - :vartype type: str - :ivar scope: The role eligibility schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. - :vartype role_eligibility_schedule_id: str - :ivar status: The status of the role eligibility schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar start_date_time: The startDateTime of the role eligibility schedule instance. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The endDateTime of the role eligibility schedule instance. - :vartype end_date_time: ~datetime.datetime - :ivar member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule was created. - :vartype created_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_eligibility_schedule_id": {"key": "properties.roleEligibilityScheduleId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_eligibility_schedule_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role eligibility schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. - :paramtype role_eligibility_schedule_id: str - :keyword status: The status of the role eligibility schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :keyword start_date_time: The startDateTime of the role eligibility schedule instance. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The endDateTime of the role eligibility schedule instance. - :paramtype end_date_time: ~datetime.datetime - :keyword member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role eligibility schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_eligibility_schedule_id = role_eligibility_schedule_id - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.member_type = member_type - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.expanded_properties = expanded_properties - - -class RoleEligibilityScheduleInstanceFilter(_serialization.Model): - """Role eligibility schedule instance filter. - - :ivar principal_id: Returns role eligibility schedule instances of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :vartype role_definition_id: str - :ivar status: Returns role eligibility schedule instances of the specific status. - :vartype status: str - :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a - specific role eligibility schedule. - :vartype role_eligibility_schedule_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "role_eligibility_schedule_id": {"key": "roleEligibilityScheduleId", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - role_eligibility_schedule_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility schedule instances of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :paramtype role_definition_id: str - :keyword status: Returns role eligibility schedule instances of the specific status. - :paramtype status: str - :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to - a specific role eligibility schedule. - :paramtype role_eligibility_schedule_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - self.role_eligibility_schedule_id = role_eligibility_schedule_id - - -class RoleEligibilityScheduleInstanceListResult(_serialization.Model): - """Role eligibility schedule instance list operation result. - - :ivar value: Role eligibility schedule instance list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilityScheduleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role eligibility schedule instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleListResult(_serialization.Model): - """role eligibility schedule list operation result. - - :ivar value: role eligibility schedule list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilitySchedule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilitySchedule"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: role eligibility schedule list. - :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Eligibility schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule request ID. - :vartype id: str - :ivar name: The role eligibility schedule request name. - :vartype name: str - :ivar type: The role eligibility schedule request type. - :vartype type: str - :ivar scope: The role eligibility schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType - :ivar status: The status of the role eligibility schedule request. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status - :ivar approval_id: The approvalId of the role eligibility schedule request. - :vartype approval_id: str - :ivar schedule_info: Schedule info of the role eligibility schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :vartype target_role_eligibility_schedule_id: str - :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id - being updated. - :vartype target_role_eligibility_schedule_instance_id: str - :ivar justification: Justification for the role eligibility. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role eligibility. - :vartype ticket_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - }, - "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, - "target_role_eligibility_schedule_instance_id": { - "key": "properties.targetRoleEligibilityScheduleInstanceId", - "type": "str", - }, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, - target_role_eligibility_schedule_id: Optional[str] = None, - target_role_eligibility_schedule_instance_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType - :keyword schedule_info: Schedule info of the role eligibility schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :paramtype target_role_eligibility_schedule_id: str - :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance - id being updated. - :paramtype target_role_eligibility_schedule_instance_id: str - :keyword justification: Justification for the role eligibility. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role eligibility. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.schedule_info = schedule_info - self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id - self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleEligibilityScheduleRequestFilter(_serialization.Model): - """Role eligibility schedule request filter. - - :ivar principal_id: Returns role eligibility requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role eligibility requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role eligibility requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role eligibility requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role eligibility requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleEligibilityScheduleRequestListResult(_serialization.Model): - """Role eligibility schedule request list operation result. - - :ivar value: Role eligibility schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role eligibility schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role eligibility schedule. - - :ivar start_date_time: Start DateTime of the role eligibility schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role eligibility schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role eligibility schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role eligibility schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role eligibility schedule. - - :ivar type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type - :ivar end_date_time: End DateTime of the role eligibility schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role eligibility schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type - :keyword end_date_time: End DateTime of the role eligibility schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role eligibility schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role eligibility. - - :ivar ticket_number: Ticket number for the role eligibility. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role eligibility. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role eligibility. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role eligibility. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system - - -class RoleManagementPolicy(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :ivar scope: The role management policy scope. - :vartype scope: str - :ivar display_name: The role management policy display name. - :vartype display_name: str - :ivar description: The role management policy description. - :vartype description: str - :ivar is_organization_default: The role management policy is default policy. - :vartype is_organization_default: bool - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01.models.Principal - :ivar last_modified_date_time: The last modified date time. - :vartype last_modified_date_time: ~datetime.datetime - :ivar rules: The rule applied to the policy. - :vartype rules: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] - :ivar effective_rules: The readonly computed rule applied to the policy. - :vartype effective_rules: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] - :ivar policy_properties: Additional properties of scope. - :vartype policy_properties: ~azure.mgmt.authorization.v2020_10_01.models.PolicyProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_modified_by": {"readonly": True}, - "last_modified_date_time": {"readonly": True}, - "effective_rules": {"readonly": True}, - "policy_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "is_organization_default": {"key": "properties.isOrganizationDefault", "type": "bool"}, - "last_modified_by": {"key": "properties.lastModifiedBy", "type": "Principal"}, - "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, - "rules": {"key": "properties.rules", "type": "[RoleManagementPolicyRule]"}, - "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, - "policy_properties": {"key": "properties.policyProperties", "type": "PolicyProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - is_organization_default: Optional[bool] = None, - rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role management policy scope. - :paramtype scope: str - :keyword display_name: The role management policy display name. - :paramtype display_name: str - :keyword description: The role management policy description. - :paramtype description: str - :keyword is_organization_default: The role management policy is default policy. - :paramtype is_organization_default: bool - :keyword rules: The rule applied to the policy. - :paramtype rules: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.display_name = display_name - self.description = description - self.is_organization_default = is_organization_default - self.last_modified_by = None - self.last_modified_date_time = None - self.rules = rules - self.effective_rules = None - self.policy_properties = None - - -class RoleManagementPolicyRule(_serialization.Model): - """The role management policy rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, - RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, - RoleManagementPolicyNotificationRule - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - } - - _subtype_map = { - "rule_type": { - "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", - } - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - """ - super().__init__(**kwargs) - self.id = id - self.rule_type: Optional[str] = None - self.target = target - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy approval rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :ivar setting: The approval setting. - :vartype setting: ~azure.mgmt.authorization.v2020_10_01.models.ApprovalSettings - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "setting": {"key": "setting", "type": "ApprovalSettings"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - setting: Optional["_models.ApprovalSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :keyword setting: The approval setting. - :paramtype setting: ~azure.mgmt.authorization.v2020_10_01.models.ApprovalSettings - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyApprovalRule" - self.setting = setting - - -class RoleManagementPolicyAssignment(_serialization.Model): - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :ivar scope: The role management policy scope. - :vartype scope: str - :ivar role_definition_id: The role definition of management policy assignment. - :vartype role_definition_id: str - :ivar policy_id: The policy id role management policy assignment. - :vartype policy_id: str - :ivar effective_rules: The readonly computed rule applied to the policy. - :vartype effective_rules: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] - :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. - :vartype policy_assignment_properties: - ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "effective_rules": {"readonly": True}, - "policy_assignment_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "policy_id": {"key": "properties.policyId", "type": "str"}, - "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, - "policy_assignment_properties": { - "key": "properties.policyAssignmentProperties", - "type": "PolicyAssignmentProperties", - }, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - policy_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role management policy scope. - :paramtype scope: str - :keyword role_definition_id: The role definition of management policy assignment. - :paramtype role_definition_id: str - :keyword policy_id: The policy id role management policy assignment. - :paramtype policy_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.policy_id = policy_id - self.effective_rules = None - self.policy_assignment_properties = None - - -class RoleManagementPolicyAssignmentListResult(_serialization.Model): - """Role management policy assignment list operation result. - - :ivar value: Role management policy assignment list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleManagementPolicyAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role management policy assignment list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy authentication context rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :ivar is_enabled: The value indicating if rule is enabled. - :vartype is_enabled: bool - :ivar claim_value: The claim value. - :vartype claim_value: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "claim_value": {"key": "claimValue", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_enabled: Optional[bool] = None, - claim_value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :keyword is_enabled: The value indicating if rule is enabled. - :paramtype is_enabled: bool - :keyword claim_value: The claim value. - :paramtype claim_value: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" - self.is_enabled = is_enabled - self.claim_value = claim_value - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy enablement rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :ivar enabled_rules: The list of enabled rules. - :vartype enabled_rules: list[str or - ~azure.mgmt.authorization.v2020_10_01.models.EnablementRules] - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "enabled_rules": {"key": "enabledRules", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :keyword enabled_rules: The list of enabled rules. - :paramtype enabled_rules: list[str or - ~azure.mgmt.authorization.v2020_10_01.models.EnablementRules] - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyEnablementRule" - self.enabled_rules = enabled_rules - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy expiration rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :ivar is_expiration_required: The value indicating whether expiration is required. - :vartype is_expiration_required: bool - :ivar maximum_duration: The maximum duration of expiration in timespan. - :vartype maximum_duration: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, - "maximum_duration": {"key": "maximumDuration", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_expiration_required: Optional[bool] = None, - maximum_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :keyword is_expiration_required: The value indicating whether expiration is required. - :paramtype is_expiration_required: bool - :keyword maximum_duration: The maximum duration of expiration in timespan. - :paramtype maximum_duration: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyExpirationRule" - self.is_expiration_required = is_expiration_required - self.maximum_duration = maximum_duration - - -class RoleManagementPolicyListResult(_serialization.Model): - """Role management policy list operation result. - - :ivar value: Role management policy list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleManagementPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleManagementPolicy"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role management policy list. - :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy notification rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :ivar notification_type: The type of notification. "Email" - :vartype notification_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.NotificationDeliveryMechanism - :ivar notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :vartype notification_level: str or - ~azure.mgmt.authorization.v2020_10_01.models.NotificationLevel - :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :vartype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RecipientType - :ivar notification_recipients: The list of notification recipients. - :vartype notification_recipients: list[str] - :ivar is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :vartype is_default_recipients_enabled: bool - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "notification_type": {"key": "notificationType", "type": "str"}, - "notification_level": {"key": "notificationLevel", "type": "str"}, - "recipient_type": {"key": "recipientType", "type": "str"}, - "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, - "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, - notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, - recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, - notification_recipients: Optional[List[str]] = None, - is_default_recipients_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget - :keyword notification_type: The type of notification. "Email" - :paramtype notification_type: str or - ~azure.mgmt.authorization.v2020_10_01.models.NotificationDeliveryMechanism - :keyword notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :paramtype notification_level: str or - ~azure.mgmt.authorization.v2020_10_01.models.NotificationLevel - :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :paramtype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RecipientType - :keyword notification_recipients: The list of notification recipients. - :paramtype notification_recipients: list[str] - :keyword is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :paramtype is_default_recipients_enabled: bool - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyNotificationRule" - self.notification_type = notification_type - self.notification_level = notification_level - self.recipient_type = recipient_type - self.notification_recipients = notification_recipients - self.is_default_recipients_enabled = is_default_recipients_enabled - - -class RoleManagementPolicyRuleTarget(_serialization.Model): - """The role management policy rule target. - - :ivar caller: The caller of the setting. - :vartype caller: str - :ivar operations: The type of operation. - :vartype operations: list[str] - :ivar level: The assignment level to which rule is applied. - :vartype level: str - :ivar target_objects: The list of target objects. - :vartype target_objects: list[str] - :ivar inheritable_settings: The list of inheritable settings. - :vartype inheritable_settings: list[str] - :ivar enforced_settings: The list of enforced settings. - :vartype enforced_settings: list[str] - """ - - _attribute_map = { - "caller": {"key": "caller", "type": "str"}, - "operations": {"key": "operations", "type": "[str]"}, - "level": {"key": "level", "type": "str"}, - "target_objects": {"key": "targetObjects", "type": "[str]"}, - "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, - "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, - } - - def __init__( - self, - *, - caller: Optional[str] = None, - operations: Optional[List[str]] = None, - level: Optional[str] = None, - target_objects: Optional[List[str]] = None, - inheritable_settings: Optional[List[str]] = None, - enforced_settings: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword caller: The caller of the setting. - :paramtype caller: str - :keyword operations: The type of operation. - :paramtype operations: list[str] - :keyword level: The assignment level to which rule is applied. - :paramtype level: str - :keyword target_objects: The list of target objects. - :paramtype target_objects: list[str] - :keyword inheritable_settings: The list of inheritable settings. - :paramtype inheritable_settings: list[str] - :keyword enforced_settings: The list of enforced settings. - :paramtype enforced_settings: list[str] - """ - super().__init__(**kwargs) - self.caller = caller - self.operations = operations - self.level = level - self.target_objects = target_objects - self.inheritable_settings = inheritable_settings - self.enforced_settings = enforced_settings - - -class UserSet(_serialization.Model): - """The detail of a user. - - :ivar user_type: The type of user. Known values are: "User" and "Group". - :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01.models.UserType - :ivar is_backup: The value indicating whether the user is a backup fallback approver. - :vartype is_backup: bool - :ivar id: The object id of the user. - :vartype id: str - :ivar description: The description of the user. - :vartype description: str - """ - - _attribute_map = { - "user_type": {"key": "userType", "type": "str"}, - "is_backup": {"key": "isBackup", "type": "bool"}, - "id": {"key": "id", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - user_type: Optional[Union[str, "_models.UserType"]] = None, - is_backup: Optional[bool] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_type: The type of user. Known values are: "User" and "Group". - :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01.models.UserType - :keyword is_backup: The value indicating whether the user is a backup fallback approver. - :paramtype is_backup: bool - :keyword id: The object id of the user. - :paramtype id: str - :keyword description: The description of the user. - :paramtype description: str - """ - super().__init__(**kwargs) - self.user_type = user_type - self.is_backup = is_backup - self.id = id - self.description = description diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py deleted file mode 100644 index 31a4ba4b86ec..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._eligible_child_resources_operations import EligibleChildResourcesOperations -from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations -from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations -from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations -from ._role_management_policies_operations import RoleManagementPoliciesOperations -from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "EligibleChildResourcesOperations", - "RoleAssignmentSchedulesOperations", - "RoleAssignmentScheduleInstancesOperations", - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilitySchedulesOperations", - "RoleEligibilityScheduleInstancesOperations", - "RoleEligibilityScheduleRequestsOperations", - "RoleManagementPoliciesOperations", - "RoleManagementPolicyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py deleted file mode 100644 index 1673bed51664..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,160 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - EligibleChildResourcesOperations, - RoleAssignmentScheduleInstancesOperations, - RoleAssignmentScheduleRequestsOperations, - RoleAssignmentSchedulesOperations, - RoleAssignmentsOperations, - RoleEligibilityScheduleInstancesOperations, - RoleEligibilityScheduleRequestsOperations, - RoleEligibilitySchedulesOperations, - RoleManagementPoliciesOperations, - RoleManagementPolicyAssignmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentsOperations - :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: - azure.mgmt.authorization.v2020_10_01_preview.operations.EligibleChildResourcesOperations - :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentSchedulesOperations - :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleInstancesOperations - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations - operations - :vartype role_eligibility_schedule_instances: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleInstancesOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleRequestsOperations - :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPoliciesOperations - :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: - azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py deleted file mode 100644 index a86bb2b1c86e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json deleted file mode 100644 index 90e687cae95a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "chosen_version": "2020-10-01-preview", - "total_api_version_list": ["2020-10-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "role_assignments": "RoleAssignmentsOperations", - "eligible_child_resources": "EligibleChildResourcesOperations", - "role_assignment_schedules": "RoleAssignmentSchedulesOperations", - "role_assignment_schedule_instances": "RoleAssignmentScheduleInstancesOperations", - "role_assignment_schedule_requests": "RoleAssignmentScheduleRequestsOperations", - "role_eligibility_schedules": "RoleEligibilitySchedulesOperations", - "role_eligibility_schedule_instances": "RoleEligibilityScheduleInstancesOperations", - "role_eligibility_schedule_requests": "RoleEligibilityScheduleRequestsOperations", - "role_management_policies": "RoleManagementPoliciesOperations", - "role_management_policy_assignments": "RoleManagementPolicyAssignmentsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index b489128766ea..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,160 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - EligibleChildResourcesOperations, - RoleAssignmentScheduleInstancesOperations, - RoleAssignmentScheduleRequestsOperations, - RoleAssignmentSchedulesOperations, - RoleAssignmentsOperations, - RoleEligibilityScheduleInstancesOperations, - RoleEligibilityScheduleRequestsOperations, - RoleEligibilitySchedulesOperations, - RoleManagementPoliciesOperations, - RoleManagementPolicyAssignmentsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations - :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations - :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations - :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations - operations - :vartype role_eligibility_schedule_instances: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations - :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations - :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: - azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py deleted file mode 100644 index bcfc50b7f475..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2020-10-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/__init__.py deleted file mode 100644 index c2480d05193e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations -from ._eligible_child_resources_operations import EligibleChildResourcesOperations -from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations -from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations -from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations -from ._role_management_policies_operations import RoleManagementPoliciesOperations -from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", - "EligibleChildResourcesOperations", - "RoleAssignmentSchedulesOperations", - "RoleAssignmentScheduleInstancesOperations", - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilitySchedulesOperations", - "RoleEligibilityScheduleInstancesOperations", - "RoleEligibilityScheduleRequestsOperations", - "RoleManagementPoliciesOperations", - "RoleManagementPolicyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py deleted file mode 100644 index bd707b2c4a44..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._eligible_child_resources_operations import build_get_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class EligibleChildResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`eligible_child_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EligibleChildResource"]: - """Get the child resources of a resource on which user has eligible access. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param 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'. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EligibleChildResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_get_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py deleted file mode 100644 index c843d2b73cbc..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py +++ /dev/null @@ -1,216 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentScheduleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleInstance"]: - """Gets role assignment schedule instances of a role assignment schedule. - - :param scope: The scope of the role assignment schedule. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleInstance: - """Gets the specified role assignment schedule instance. - - :param scope: The scope of the role assignments schedules. Required. - :type scope: str - :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the - role assignment schedule to get. Required. - :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py deleted file mode 100644 index 7149df82ace8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py +++ /dev/null @@ -1,447 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_schedule_requests_operations import ( - build_cancel_request, - build_create_request, - build_get_request, - build_list_for_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_create_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Get the specified role assignment schedule request. - - :param scope: The scope of the role assignment schedule request. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule - request to get. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleRequest"]: - """Gets role assignment schedule requests for a scope. - - :param scope: The scope of the role assignments schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role assignment schedule request. - - :param scope: The scope of the role assignment request to cancel. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - cancel. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py deleted file mode 100644 index b44a610ed4b9..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py +++ /dev/null @@ -1,216 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentSchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_schedule_name: str, **kwargs: Any - ) -> _models.RoleAssignmentSchedule: - """Get the specified role assignment schedule for a resource scope. - - :param scope: The scope of the role assignment schedule. Required. - :type scope: str - :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. - Required. - :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentSchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_name=role_assignment_schedule_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentSchedule"]: - """Gets role assignment schedules for a resource scope. - - :param scope: The scope of the role assignments schedules. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentSchedule or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py deleted file mode 100644 index 2c57a419901d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1354 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignments_operations import ( - build_create_by_id_request, - build_create_request, - build_delete_by_id_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_scope_request, - build_list_for_subscription_request, - build_validate_by_id_request, - build_validate_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_subscription( - self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List all role assignments that apply to a subscription. - - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List all role assignments that apply to a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List all role assignments that apply to a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). Required. - :type resource_type: str - :param resource_name: The resource name. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace_async - async def delete( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - async def validate( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_validate_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignment"]: - """List all role assignments that apply to a scope. - - :param 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}'. - Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace_async - async def get_by_id( - self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_assignment_id=role_assignment_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - async def create_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace_async - async def delete_by_id( - self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_assignment_id=role_assignment_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - async def validate_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_validate_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py deleted file mode 100644 index 6561dfb24dd5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_eligibility_schedule_instances_operations import ( - build_get_request, - build_list_for_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleEligibilityScheduleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleInstance"]: - """Gets role eligibility schedule instances of a role eligibility schedule. - - :param scope: The scope of the role eligibility schedule. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - - @distributed_trace_async - async def get( - self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleInstance: - """Gets the specified role eligibility schedule instance. - - :param scope: The scope of the role eligibility schedules. Required. - :type scope: str - :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the - role eligibility schedule to get. Required. - :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py deleted file mode 100644 index ee9875766ca6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py +++ /dev/null @@ -1,447 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_eligibility_schedule_requests_operations import ( - build_cancel_request, - build_create_request, - build_get_request, - build_list_for_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleEligibilityScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_create_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace_async - async def get( - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Get the specified role eligibility schedule request. - - :param scope: The scope of the role eligibility schedule request. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule - request to get. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleRequest"]: - """Gets role eligibility schedule requests for a scope. - - :param scope: The scope of the role eligibility schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role eligibility schedule request. - - :param scope: The scope of the role eligibility request to cancel. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - cancel. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py deleted file mode 100644 index 5ff534c83217..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py +++ /dev/null @@ -1,216 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleEligibilitySchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any - ) -> _models.RoleEligibilitySchedule: - """Get the specified role eligibility schedule for a resource scope. - - :param scope: The scope of the role eligibility schedule. Required. - :type scope: str - :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. - Required. - :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilitySchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_name=role_eligibility_schedule_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilitySchedule"]: - """Gets role eligibility schedules for a resource scope. - - :param scope: The scope of the role eligibility schedules. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilitySchedule or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py deleted file mode 100644 index da805b810844..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py +++ /dev/null @@ -1,415 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_management_policies_operations import ( - build_delete_request, - build_get_request, - build_list_for_scope_request, - build_update_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleManagementPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_management_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: - """Get the specified role management policy for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to get. - Required. - :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @overload - async def update( - self, - scope: str, - role_management_policy_name: str, - parameters: _models.RoleManagementPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - scope: str, - role_management_policy_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - scope: str, - role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleManagementPolicy") - - request = build_update_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_name: str, **kwargs: Any - ) -> None: - """Delete a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: - """Gets role management policies for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py deleted file mode 100644 index 818a1455ed84..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py +++ /dev/null @@ -1,418 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_management_policy_assignments_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_for_scope_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleManagementPolicyAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_management_policy_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Get the specified role management policy assignment for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to get. Required. - :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @overload - async def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: _models.RoleManagementPolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - - request = build_create_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> None: - """Delete a role management policy assignment. - - :param scope: The scope of the role management policy assignment to delete. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to delete. Required. - :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: - """Gets role management assignment policies for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py deleted file mode 100644 index 3dac2f0b2994..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py +++ /dev/null @@ -1,167 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ApprovalSettings -from ._models_py3 import ApprovalStage -from ._models_py3 import CloudErrorBody -from ._models_py3 import EligibleChildResource -from ._models_py3 import EligibleChildResourcesListResult -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import ExpandedProperties -from ._models_py3 import ExpandedPropertiesPrincipal -from ._models_py3 import ExpandedPropertiesRoleDefinition -from ._models_py3 import ExpandedPropertiesScope -from ._models_py3 import Permission -from ._models_py3 import PolicyAssignmentProperties -from ._models_py3 import PolicyAssignmentPropertiesPolicy -from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition -from ._models_py3 import PolicyAssignmentPropertiesScope -from ._models_py3 import PolicyProperties -from ._models_py3 import PolicyPropertiesScope -from ._models_py3 import Principal -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult -from ._models_py3 import RoleAssignmentSchedule -from ._models_py3 import RoleAssignmentScheduleFilter -from ._models_py3 import RoleAssignmentScheduleInstance -from ._models_py3 import RoleAssignmentScheduleInstanceFilter -from ._models_py3 import RoleAssignmentScheduleInstanceListResult -from ._models_py3 import RoleAssignmentScheduleListResult -from ._models_py3 import RoleAssignmentScheduleRequest -from ._models_py3 import RoleAssignmentScheduleRequestFilter -from ._models_py3 import RoleAssignmentScheduleRequestListResult -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo -from ._models_py3 import RoleEligibilitySchedule -from ._models_py3 import RoleEligibilityScheduleFilter -from ._models_py3 import RoleEligibilityScheduleInstance -from ._models_py3 import RoleEligibilityScheduleInstanceFilter -from ._models_py3 import RoleEligibilityScheduleInstanceListResult -from ._models_py3 import RoleEligibilityScheduleListResult -from ._models_py3 import RoleEligibilityScheduleRequest -from ._models_py3 import RoleEligibilityScheduleRequestFilter -from ._models_py3 import RoleEligibilityScheduleRequestListResult -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo -from ._models_py3 import RoleManagementPolicy -from ._models_py3 import RoleManagementPolicyApprovalRule -from ._models_py3 import RoleManagementPolicyAssignment -from ._models_py3 import RoleManagementPolicyAssignmentListResult -from ._models_py3 import RoleManagementPolicyAuthenticationContextRule -from ._models_py3 import RoleManagementPolicyEnablementRule -from ._models_py3 import RoleManagementPolicyExpirationRule -from ._models_py3 import RoleManagementPolicyListResult -from ._models_py3 import RoleManagementPolicyNotificationRule -from ._models_py3 import RoleManagementPolicyRule -from ._models_py3 import RoleManagementPolicyRuleTarget -from ._models_py3 import UserSet -from ._models_py3 import ValidationResponse -from ._models_py3 import ValidationResponseErrorInfo - -from ._authorization_management_client_enums import ApprovalMode -from ._authorization_management_client_enums import AssignmentType -from ._authorization_management_client_enums import EnablementRules -from ._authorization_management_client_enums import MemberType -from ._authorization_management_client_enums import NotificationDeliveryMechanism -from ._authorization_management_client_enums import NotificationLevel -from ._authorization_management_client_enums import PrincipalType -from ._authorization_management_client_enums import RecipientType -from ._authorization_management_client_enums import RequestType -from ._authorization_management_client_enums import RoleManagementPolicyRuleType -from ._authorization_management_client_enums import Status -from ._authorization_management_client_enums import Type -from ._authorization_management_client_enums import UserType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApprovalSettings", - "ApprovalStage", - "CloudErrorBody", - "EligibleChildResource", - "EligibleChildResourcesListResult", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "ExpandedProperties", - "ExpandedPropertiesPrincipal", - "ExpandedPropertiesRoleDefinition", - "ExpandedPropertiesScope", - "Permission", - "PolicyAssignmentProperties", - "PolicyAssignmentPropertiesPolicy", - "PolicyAssignmentPropertiesRoleDefinition", - "PolicyAssignmentPropertiesScope", - "PolicyProperties", - "PolicyPropertiesScope", - "Principal", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "RoleAssignmentSchedule", - "RoleAssignmentScheduleFilter", - "RoleAssignmentScheduleInstance", - "RoleAssignmentScheduleInstanceFilter", - "RoleAssignmentScheduleInstanceListResult", - "RoleAssignmentScheduleListResult", - "RoleAssignmentScheduleRequest", - "RoleAssignmentScheduleRequestFilter", - "RoleAssignmentScheduleRequestListResult", - "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", - "RoleAssignmentScheduleRequestPropertiesTicketInfo", - "RoleEligibilitySchedule", - "RoleEligibilityScheduleFilter", - "RoleEligibilityScheduleInstance", - "RoleEligibilityScheduleInstanceFilter", - "RoleEligibilityScheduleInstanceListResult", - "RoleEligibilityScheduleListResult", - "RoleEligibilityScheduleRequest", - "RoleEligibilityScheduleRequestFilter", - "RoleEligibilityScheduleRequestListResult", - "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", - "RoleEligibilityScheduleRequestPropertiesTicketInfo", - "RoleManagementPolicy", - "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAssignment", - "RoleManagementPolicyAssignmentListResult", - "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyListResult", - "RoleManagementPolicyNotificationRule", - "RoleManagementPolicyRule", - "RoleManagementPolicyRuleTarget", - "UserSet", - "ValidationResponse", - "ValidationResponseErrorInfo", - "ApprovalMode", - "AssignmentType", - "EnablementRules", - "MemberType", - "NotificationDeliveryMechanism", - "NotificationLevel", - "PrincipalType", - "RecipientType", - "RequestType", - "RoleManagementPolicyRuleType", - "Status", - "Type", - "UserType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index b7fe646a9920..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,140 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - SINGLE_STAGE = "SingleStage" - SERIAL = "Serial" - PARALLEL = "Parallel" - NO_APPROVAL = "NoApproval" - - -class AssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Assignment type of the role assignment schedule.""" - - ACTIVATED = "Activated" - ASSIGNED = "Assigned" - - -class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of enablement rule.""" - - MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" - JUSTIFICATION = "Justification" - TICKETING = "Ticketing" - - -class MemberType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Membership type of the role assignment schedule.""" - - INHERITED = "Inherited" - DIRECT = "Direct" - GROUP = "Group" - - -class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of notification.""" - - EMAIL = "Email" - - -class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The notification level.""" - - NONE = "None" - CRITICAL = "Critical" - ALL = "All" - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" - DEVICE = "Device" - - -class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recipient type.""" - - REQUESTOR = "Requestor" - APPROVER = "Approver" - ADMIN = "Admin" - - -class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" - - ADMIN_ASSIGN = "AdminAssign" - ADMIN_REMOVE = "AdminRemove" - ADMIN_UPDATE = "AdminUpdate" - ADMIN_EXTEND = "AdminExtend" - ADMIN_RENEW = "AdminRenew" - SELF_ACTIVATE = "SelfActivate" - SELF_DEACTIVATE = "SelfDeactivate" - SELF_EXTEND = "SelfExtend" - SELF_RENEW = "SelfRenew" - - -class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" - ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" - ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" - ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" - ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" - - -class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the role assignment schedule.""" - - ACCEPTED = "Accepted" - PENDING_EVALUATION = "PendingEvaluation" - GRANTED = "Granted" - DENIED = "Denied" - PENDING_PROVISIONING = "PendingProvisioning" - PROVISIONED = "Provisioned" - PENDING_REVOCATION = "PendingRevocation" - REVOKED = "Revoked" - CANCELED = "Canceled" - FAILED = "Failed" - PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" - PENDING_APPROVAL = "PendingApproval" - FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" - PENDING_ADMIN_DECISION = "PendingAdminDecision" - ADMIN_APPROVED = "AdminApproved" - ADMIN_DENIED = "AdminDenied" - TIMED_OUT = "TimedOut" - PROVISIONING_STARTED = "ProvisioningStarted" - INVALID = "Invalid" - PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" - SCHEDULE_CREATED = "ScheduleCreated" - PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of the role assignment schedule expiration.""" - - AFTER_DURATION = "AfterDuration" - AFTER_DATE_TIME = "AfterDateTime" - NO_EXPIRATION = "NoExpiration" - - -class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of user.""" - - USER = "User" - GROUP = "Group" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py deleted file mode 100644 index f75709cee514..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py +++ /dev/null @@ -1,3624 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ApprovalSettings(_serialization.Model): - """The approval settings. - - :ivar is_approval_required: Determines whether approval is required or not. - :vartype is_approval_required: bool - :ivar is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :vartype is_approval_required_for_extension: bool - :ivar is_requestor_justification_required: Determine whether requestor justification is - required. - :vartype is_requestor_justification_required: bool - :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", - and "NoApproval". - :vartype approval_mode: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :ivar approval_stages: The approval stages of the request. - :vartype approval_stages: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] - """ - - _attribute_map = { - "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, - "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, - "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, - "approval_mode": {"key": "approvalMode", "type": "str"}, - "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, - } - - def __init__( - self, - *, - is_approval_required: Optional[bool] = None, - is_approval_required_for_extension: Optional[bool] = None, - is_requestor_justification_required: Optional[bool] = None, - approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, - approval_stages: Optional[List["_models.ApprovalStage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_approval_required: Determines whether approval is required or not. - :paramtype is_approval_required: bool - :keyword is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :paramtype is_approval_required_for_extension: bool - :keyword is_requestor_justification_required: Determine whether requestor justification is - required. - :paramtype is_requestor_justification_required: bool - :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", - "Parallel", and "NoApproval". - :paramtype approval_mode: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :keyword approval_stages: The approval stages of the request. - :paramtype approval_stages: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] - """ - super().__init__(**kwargs) - self.is_approval_required = is_approval_required - self.is_approval_required_for_extension = is_approval_required_for_extension - self.is_requestor_justification_required = is_requestor_justification_required - self.approval_mode = approval_mode - self.approval_stages = approval_stages - - -class ApprovalStage(_serialization.Model): - """The approval stage. - - :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :vartype approval_stage_time_out_in_days: int - :ivar is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :vartype is_approver_justification_required: bool - :ivar escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :vartype escalation_time_in_minutes: int - :ivar primary_approvers: The primary approver of the request. - :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. - :vartype is_escalation_enabled: bool - :ivar escalation_approvers: The escalation approver of the request. - :vartype escalation_approvers: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - """ - - _attribute_map = { - "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, - "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, - "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, - "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, - "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, - "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, - } - - def __init__( - self, - *, - approval_stage_time_out_in_days: Optional[int] = None, - is_approver_justification_required: Optional[bool] = None, - escalation_time_in_minutes: Optional[int] = None, - primary_approvers: Optional[List["_models.UserSet"]] = None, - is_escalation_enabled: Optional[bool] = None, - escalation_approvers: Optional[List["_models.UserSet"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :paramtype approval_stage_time_out_in_days: int - :keyword is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :paramtype is_approver_justification_required: bool - :keyword escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :paramtype escalation_time_in_minutes: int - :keyword primary_approvers: The primary approver of the request. - :paramtype primary_approvers: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. - :paramtype is_escalation_enabled: bool - :keyword escalation_approvers: The escalation approver of the request. - :paramtype escalation_approvers: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - """ - super().__init__(**kwargs) - self.approval_stage_time_out_in_days = approval_stage_time_out_in_days - self.is_approver_justification_required = is_approver_justification_required - self.escalation_time_in_minutes = escalation_time_in_minutes - self.primary_approvers = primary_approvers - self.is_escalation_enabled = is_escalation_enabled - self.escalation_approvers = escalation_approvers - - -class CloudErrorBody(_serialization.Model): - """An error response from the service. - - :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :vartype code: str - :ivar message: A message describing the error, intended to be suitable for display in a user - interface. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :paramtype code: str - :keyword message: A message describing the error, intended to be suitable for display in a user - interface. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class EligibleChildResource(_serialization.Model): - """Eligible child resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource scope Id. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class EligibleChildResourcesListResult(_serialization.Model): - """Eligible child resources list operation result. - - :ivar value: Eligible child resource list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[EligibleChildResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.EligibleChildResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Eligible child resource list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ExpandedProperties(_serialization.Model): - """ExpandedProperties. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :ivar role_definition: Details of role definition. - :vartype role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition - :ivar principal: Details of the principal. - :vartype principal: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, - "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, - "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, - } - - def __init__( - self, - *, - scope: Optional["_models.ExpandedPropertiesScope"] = None, - role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, - principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: Details of the resource scope. - :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :keyword role_definition: Details of role definition. - :paramtype role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition - :keyword principal: Details of the principal. - :paramtype principal: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition = role_definition - self.principal = principal - - -class ExpandedPropertiesPrincipal(_serialization.Model): - """Details of the principal. - - :ivar id: Id of the principal. - :vartype id: str - :ivar display_name: Display name of the principal. - :vartype display_name: str - :ivar email: Email id of the principal. - :vartype email: str - :ivar type: Type of the principal. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "email": {"key": "email", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - email: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the principal. - :paramtype id: str - :keyword display_name: Display name of the principal. - :paramtype display_name: str - :keyword email: Email id of the principal. - :paramtype email: str - :keyword type: Type of the principal. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.email = email - self.type = type - - -class ExpandedPropertiesRoleDefinition(_serialization.Model): - """Details of role definition. - - :ivar id: Id of the role definition. - :vartype id: str - :ivar display_name: Display name of the role definition. - :vartype display_name: str - :ivar type: Type of the role definition. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the role definition. - :paramtype id: str - :keyword display_name: Display name of the role definition. - :paramtype display_name: str - :keyword type: Type of the role definition. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class ExpandedPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class PolicyAssignmentProperties(_serialization.Model): - """PolicyAssignmentProperties. - - :ivar scope: Details of the resource scope. - :vartype scope: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :ivar role_definition: Details of role definition. - :vartype role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :ivar policy: Details of the policy. - :vartype policy: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "PolicyAssignmentPropertiesScope"}, - "role_definition": {"key": "roleDefinition", "type": "PolicyAssignmentPropertiesRoleDefinition"}, - "policy": {"key": "policy", "type": "PolicyAssignmentPropertiesPolicy"}, - } - - def __init__( - self, - *, - scope: Optional["_models.PolicyAssignmentPropertiesScope"] = None, - role_definition: Optional["_models.PolicyAssignmentPropertiesRoleDefinition"] = None, - policy: Optional["_models.PolicyAssignmentPropertiesPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: Details of the resource scope. - :paramtype scope: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :keyword role_definition: Details of role definition. - :paramtype role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :keyword policy: Details of the policy. - :paramtype policy: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition = role_definition - self.policy = policy - - -class PolicyAssignmentPropertiesPolicy(_serialization.Model): - """Details of the policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the policy. - :vartype id: str - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal - :ivar last_modified_date_time: The last modified date time. - :vartype last_modified_date_time: ~datetime.datetime - """ - - _validation = { - "last_modified_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "Principal"}, - "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - last_modified_date_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the policy. - :paramtype id: str - :keyword last_modified_date_time: The last modified date time. - :paramtype last_modified_date_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.id = id - self.last_modified_by = None - self.last_modified_date_time = last_modified_date_time - - -class PolicyAssignmentPropertiesRoleDefinition(_serialization.Model): - """Details of role definition. - - :ivar id: Id of the role definition. - :vartype id: str - :ivar display_name: Display name of the role definition. - :vartype display_name: str - :ivar type: Type of the role definition. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the role definition. - :paramtype id: str - :keyword display_name: Display name of the role definition. - :paramtype display_name: str - :keyword type: Type of the role definition. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class PolicyAssignmentPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class PolicyProperties(_serialization.Model): - """PolicyProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyPropertiesScope - """ - - _validation = { - "scope": {"readonly": True}, - } - - _attribute_map = { - "scope": {"key": "scope", "type": "PolicyPropertiesScope"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.scope = None - - -class PolicyPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class Principal(_serialization.Model): - """The name of the entity last modified it. - - :ivar id: The id of the principal made changes. - :vartype id: str - :ivar display_name: The name of the principal made changes. - :vartype display_name: str - :ivar type: Type of principal such as user , group etc. - :vartype type: str - :ivar email: Email of principal. - :vartype email: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - email: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the principal made changes. - :paramtype id: str - :keyword display_name: The name of the principal made changes. - :paramtype display_name: str - :keyword type: Type of principal such as user , group etc. - :paramtype type: str - :keyword email: Email of principal. - :paramtype email: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - self.email = email - - -class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.description = description - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role assignment create parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. Required. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. Required. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "scope": {"readonly": True}, - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - role_definition_id: str, - principal_id: str, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. Required. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. Required. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.description = description - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RoleAssignmentSchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignment schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule Id. - :vartype id: str - :ivar name: The role assignment schedule name. - :vartype name: str - :ivar type: The role assignment schedule type. - :vartype type: str - :ivar scope: The role assignment schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :vartype role_assignment_schedule_request_id: str - :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated - this roleAssignmentSchedule. - :vartype linked_role_eligibility_schedule_id: str - :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :vartype assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :ivar member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :ivar status: The status of the role assignment schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar start_date_time: Start DateTime when role assignment schedule. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: End DateTime when role assignment schedule. - :vartype end_date_time: ~datetime.datetime - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: DateTime when role assignment schedule was modified. - :vartype updated_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_assignment_schedule_request_id": {"key": "properties.roleAssignmentScheduleRequestId", "type": "str"}, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "assignment_type": {"key": "properties.assignmentType", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_assignment_schedule_request_id: Optional[str] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - updated_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :paramtype role_assignment_schedule_request_id: str - :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to - activated this roleAssignmentSchedule. - :paramtype linked_role_eligibility_schedule_id: str - :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :paramtype assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :keyword member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :keyword status: The status of the role assignment schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :keyword start_date_time: Start DateTime when role assignment schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: End DateTime when role assignment schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role assignment schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword updated_on: DateTime when role assignment schedule was modified. - :paramtype updated_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_assignment_schedule_request_id = role_assignment_schedule_request_id - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.assignment_type = assignment_type - self.member_type = member_type - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.updated_on = updated_on - self.expanded_properties = expanded_properties - - -class RoleAssignmentScheduleFilter(_serialization.Model): - """Role assignment schedule filter. - - :ivar principal_id: Returns role assignment schedule of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment schedule of the specific role definition. - :vartype role_definition_id: str - :ivar status: Returns role assignment schedule instances of the specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment schedule of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment schedule of the specific role definition. - :paramtype role_definition_id: str - :keyword status: Returns role assignment schedule instances of the specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - - -class RoleAssignmentScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Information about current or upcoming role assignment schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule instance ID. - :vartype id: str - :ivar name: The role assignment schedule instance name. - :vartype name: str - :ivar type: The role assignment schedule instance type. - :vartype type: str - :ivar scope: The role assignment schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar role_assignment_schedule_id: Id of the master role assignment schedule. - :vartype role_assignment_schedule_id: str - :ivar origin_role_assignment_id: Role Assignment Id in external system. - :vartype origin_role_assignment_id: str - :ivar status: The status of the role assignment schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar start_date_time: The startDateTime of the role assignment schedule instance. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The endDateTime of the role assignment schedule instance. - :vartype end_date_time: ~datetime.datetime - :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :vartype linked_role_eligibility_schedule_id: str - :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to - this roleAssignmentScheduleInstance. - :vartype linked_role_eligibility_schedule_instance_id: str - :ivar assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :vartype assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :ivar member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule was created. - :vartype created_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_assignment_schedule_id": {"key": "properties.roleAssignmentScheduleId", "type": "str"}, - "origin_role_assignment_id": {"key": "properties.originRoleAssignmentId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "linked_role_eligibility_schedule_instance_id": { - "key": "properties.linkedRoleEligibilityScheduleInstanceId", - "type": "str", - }, - "assignment_type": {"key": "properties.assignmentType", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_assignment_schedule_id: Optional[str] = None, - origin_role_assignment_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - linked_role_eligibility_schedule_instance_id: Optional[str] = None, - assignment_type: Optional[Union[str, "_models.AssignmentType"]] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role assignment schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword role_assignment_schedule_id: Id of the master role assignment schedule. - :paramtype role_assignment_schedule_id: str - :keyword origin_role_assignment_id: Role Assignment Id in external system. - :paramtype origin_role_assignment_id: str - :keyword status: The status of the role assignment schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :keyword start_date_time: The startDateTime of the role assignment schedule instance. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The endDateTime of the role assignment schedule instance. - :paramtype end_date_time: ~datetime.datetime - :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :paramtype linked_role_eligibility_schedule_id: str - :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :paramtype linked_role_eligibility_schedule_instance_id: str - :keyword assignment_type: Assignment type of the role assignment schedule. Known values are: - "Activated" and "Assigned". - :paramtype assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :keyword member_type: Membership type of the role assignment schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role assignment schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_assignment_schedule_id = role_assignment_schedule_id - self.origin_role_assignment_id = origin_role_assignment_id - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id - self.assignment_type = assignment_type - self.member_type = member_type - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.expanded_properties = expanded_properties - - -class RoleAssignmentScheduleInstanceFilter(_serialization.Model): - """Role assignment schedule instance filter. - - :ivar principal_id: Returns role assignment schedule instances of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :vartype role_definition_id: str - :ivar status: Returns role assignment schedule instances of the specific status. - :vartype status: str - :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :vartype role_assignment_schedule_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "role_assignment_schedule_id": {"key": "roleAssignmentScheduleId", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - role_assignment_schedule_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment schedule instances of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :paramtype role_definition_id: str - :keyword status: Returns role assignment schedule instances of the specific status. - :paramtype status: str - :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :paramtype role_assignment_schedule_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - self.role_assignment_schedule_id = role_assignment_schedule_id - - -class RoleAssignmentScheduleInstanceListResult(_serialization.Model): - """Role assignment schedule instance list operation result. - - :ivar value: Role assignment schedule instance list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentScheduleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentScheduleInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleListResult(_serialization.Model): - """Role assignment schedule list operation result. - - :ivar value: Role assignment schedule list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentSchedule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentSchedule"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignment schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule request ID. - :vartype id: str - :ivar name: The role assignment schedule request name. - :vartype name: str - :ivar type: The role assignment schedule request type. - :vartype type: str - :ivar scope: The role assignment schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar approval_id: The approvalId of the role assignment schedule request. - :vartype approval_id: str - :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role - assignment schedule id being updated. - :vartype target_role_assignment_schedule_id: str - :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :vartype target_role_assignment_schedule_instance_id: str - :ivar schedule_info: Schedule info of the role assignment schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :vartype linked_role_eligibility_schedule_id: str - :ivar justification: Justification for the role assignment. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role assignment. - :vartype ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, - "target_role_assignment_schedule_instance_id": { - "key": "properties.targetRoleAssignmentScheduleInstanceId", - "type": "str", - }, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - }, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - target_role_assignment_schedule_id: Optional[str] = None, - target_role_assignment_schedule_instance_id: Optional[str] = None, - schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :paramtype target_role_assignment_schedule_id: str - :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :paramtype target_role_assignment_schedule_instance_id: str - :keyword schedule_info: Schedule info of the role assignment schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :paramtype linked_role_eligibility_schedule_id: str - :keyword justification: Justification for the role assignment. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role assignment. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.target_role_assignment_schedule_id = target_role_assignment_schedule_id - self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id - self.schedule_info = schedule_info - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleAssignmentScheduleRequestFilter(_serialization.Model): - """Role assignment schedule request filter. - - :ivar principal_id: Returns role assignment requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role assignment requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role assignment requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role assignment requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role assignment requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleAssignmentScheduleRequestListResult(_serialization.Model): - """Role assignment schedule request list operation result. - - :ivar value: Role assignment schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role assignment schedule. - - :ivar start_date_time: Start DateTime of the role assignment schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role assignment schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role assignment schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role assignment schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role assignment schedule. - - :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", - "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :ivar end_date_time: End DateTime of the role assignment schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role assignment schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role assignment schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :keyword end_date_time: End DateTime of the role assignment schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role assignment schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role assignment. - - :ivar ticket_number: Ticket number for the role assignment. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role assignment. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role assignment. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role assignment. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system - - -class RoleEligibilitySchedule(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role eligibility schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule Id. - :vartype id: str - :ivar name: The role eligibility schedule name. - :vartype name: str - :ivar type: The role eligibility schedule type. - :vartype type: str - :ivar scope: The role eligibility schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :vartype role_eligibility_schedule_request_id: str - :ivar member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :ivar status: The status of the role eligibility schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar start_date_time: Start DateTime when role eligibility schedule. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: End DateTime when role eligibility schedule. - :vartype end_date_time: ~datetime.datetime - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: DateTime when role eligibility schedule was modified. - :vartype updated_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_eligibility_schedule_request_id": {"key": "properties.roleEligibilityScheduleRequestId", "type": "str"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_eligibility_schedule_request_id: Optional[str] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - updated_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role eligibility schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :paramtype role_eligibility_schedule_request_id: str - :keyword member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :keyword status: The status of the role eligibility schedule. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :keyword start_date_time: Start DateTime when role eligibility schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: End DateTime when role eligibility schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role eligibility schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword updated_on: DateTime when role eligibility schedule was modified. - :paramtype updated_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id - self.member_type = member_type - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.updated_on = updated_on - self.expanded_properties = expanded_properties - - -class RoleEligibilityScheduleFilter(_serialization.Model): - """Role eligibility schedule filter. - - :ivar principal_id: Returns role eligibility schedule of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. - :vartype role_definition_id: str - :ivar status: Returns role eligibility schedule of the specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility schedule of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. - :paramtype role_definition_id: str - :keyword status: Returns role eligibility schedule of the specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - - -class RoleEligibilityScheduleInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Information about current or upcoming role eligibility schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule instance ID. - :vartype id: str - :ivar name: The role eligibility schedule instance name. - :vartype name: str - :ivar type: The role eligibility schedule instance type. - :vartype type: str - :ivar scope: The role eligibility schedule scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. - :vartype role_eligibility_schedule_id: str - :ivar status: The status of the role eligibility schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar start_date_time: The startDateTime of the role eligibility schedule instance. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The endDateTime of the role eligibility schedule instance. - :vartype end_date_time: ~datetime.datetime - :ivar member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule was created. - :vartype created_on: ~datetime.datetime - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "role_eligibility_schedule_id": {"key": "properties.roleEligibilityScheduleId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "member_type": {"key": "properties.memberType", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, - role_eligibility_schedule_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - member_type: Optional[Union[str, "_models.MemberType"]] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - created_on: Optional[datetime.datetime] = None, - expanded_properties: Optional["_models.ExpandedProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role eligibility schedule scope. - :paramtype scope: str - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. - :paramtype role_eligibility_schedule_id: str - :keyword status: The status of the role eligibility schedule instance. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :keyword start_date_time: The startDateTime of the role eligibility schedule instance. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The endDateTime of the role eligibility schedule instance. - :paramtype end_date_time: ~datetime.datetime - :keyword member_type: Membership type of the role eligibility schedule. Known values are: - "Inherited", "Direct", and "Group". - :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - :keyword created_on: DateTime when role eligibility schedule was created. - :paramtype created_on: ~datetime.datetime - :keyword expanded_properties: Additional properties of principal, scope and role definition. - :paramtype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.role_eligibility_schedule_id = role_eligibility_schedule_id - self.status = status - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.member_type = member_type - self.condition = condition - self.condition_version = condition_version - self.created_on = created_on - self.expanded_properties = expanded_properties - - -class RoleEligibilityScheduleInstanceFilter(_serialization.Model): - """Role eligibility schedule instance filter. - - :ivar principal_id: Returns role eligibility schedule instances of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :vartype role_definition_id: str - :ivar status: Returns role eligibility schedule instances of the specific status. - :vartype status: str - :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a - specific role eligibility schedule. - :vartype role_eligibility_schedule_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "role_eligibility_schedule_id": {"key": "roleEligibilityScheduleId", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - status: Optional[str] = None, - role_eligibility_schedule_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility schedule instances of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :paramtype role_definition_id: str - :keyword status: Returns role eligibility schedule instances of the specific status. - :paramtype status: str - :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to - a specific role eligibility schedule. - :paramtype role_eligibility_schedule_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.status = status - self.role_eligibility_schedule_id = role_eligibility_schedule_id - - -class RoleEligibilityScheduleInstanceListResult(_serialization.Model): - """Role eligibility schedule instance list operation result. - - :ivar value: Role eligibility schedule instance list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilityScheduleInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilityScheduleInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role eligibility schedule instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleListResult(_serialization.Model): - """role eligibility schedule list operation result. - - :ivar value: role eligibility schedule list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilitySchedule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilitySchedule"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: role eligibility schedule list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Eligibility schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule request ID. - :vartype id: str - :ivar name: The role eligibility schedule request name. - :vartype name: str - :ivar type: The role eligibility schedule request type. - :vartype type: str - :ivar scope: The role eligibility schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role eligibility schedule request. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar approval_id: The approvalId of the role eligibility schedule request. - :vartype approval_id: str - :ivar schedule_info: Schedule info of the role eligibility schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :vartype target_role_eligibility_schedule_id: str - :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id - being updated. - :vartype target_role_eligibility_schedule_instance_id: str - :ivar justification: Justification for the role eligibility. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role eligibility. - :vartype ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - }, - "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, - "target_role_eligibility_schedule_instance_id": { - "key": "properties.targetRoleEligibilityScheduleInstanceId", - "type": "str", - }, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, - target_role_eligibility_schedule_id: Optional[str] = None, - target_role_eligibility_schedule_instance_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :keyword schedule_info: Schedule info of the role eligibility schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :paramtype target_role_eligibility_schedule_id: str - :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance - id being updated. - :paramtype target_role_eligibility_schedule_instance_id: str - :keyword justification: Justification for the role eligibility. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role eligibility. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.schedule_info = schedule_info - self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id - self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleEligibilityScheduleRequestFilter(_serialization.Model): - """Role eligibility schedule request filter. - - :ivar principal_id: Returns role eligibility requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role eligibility requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role eligibility requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role eligibility requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role eligibility requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleEligibilityScheduleRequestListResult(_serialization.Model): - """Role eligibility schedule request list operation result. - - :ivar value: Role eligibility schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role eligibility schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role eligibility schedule. - - :ivar start_date_time: Start DateTime of the role eligibility schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role eligibility schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role eligibility schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role eligibility schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role eligibility schedule. - - :ivar type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :ivar end_date_time: End DateTime of the role eligibility schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role eligibility schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :keyword end_date_time: End DateTime of the role eligibility schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role eligibility schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role eligibility. - - :ivar ticket_number: Ticket number for the role eligibility. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role eligibility. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role eligibility. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role eligibility. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system - - -class RoleManagementPolicy(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :ivar scope: The role management policy scope. - :vartype scope: str - :ivar display_name: The role management policy display name. - :vartype display_name: str - :ivar description: The role management policy description. - :vartype description: str - :ivar is_organization_default: The role management policy is default policy. - :vartype is_organization_default: bool - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal - :ivar last_modified_date_time: The last modified date time. - :vartype last_modified_date_time: ~datetime.datetime - :ivar rules: The rule applied to the policy. - :vartype rules: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] - :ivar effective_rules: The readonly computed rule applied to the policy. - :vartype effective_rules: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] - :ivar policy_properties: Additional properties of scope. - :vartype policy_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "last_modified_by": {"readonly": True}, - "last_modified_date_time": {"readonly": True}, - "effective_rules": {"readonly": True}, - "policy_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "is_organization_default": {"key": "properties.isOrganizationDefault", "type": "bool"}, - "last_modified_by": {"key": "properties.lastModifiedBy", "type": "Principal"}, - "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, - "rules": {"key": "properties.rules", "type": "[RoleManagementPolicyRule]"}, - "effective_rules": {"key": "properties.effectiveRules", "type": "[RoleManagementPolicyRule]"}, - "policy_properties": {"key": "properties.policyProperties", "type": "PolicyProperties"}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - is_organization_default: Optional[bool] = None, - rules: Optional[List["_models.RoleManagementPolicyRule"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role management policy scope. - :paramtype scope: str - :keyword display_name: The role management policy display name. - :paramtype display_name: str - :keyword description: The role management policy description. - :paramtype description: str - :keyword is_organization_default: The role management policy is default policy. - :paramtype is_organization_default: bool - :keyword rules: The rule applied to the policy. - :paramtype rules: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.display_name = display_name - self.description = description - self.is_organization_default = is_organization_default - self.last_modified_by = None - self.last_modified_date_time = None - self.rules = rules - self.effective_rules = None - self.policy_properties = None - - -class RoleManagementPolicyRule(_serialization.Model): - """The role management policy rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, - RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, - RoleManagementPolicyNotificationRule - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - } - - _subtype_map = { - "rule_type": { - "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", - } - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - """ - super().__init__(**kwargs) - self.id = id - self.rule_type: Optional[str] = None - self.target = target - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy approval rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :ivar setting: The approval setting. - :vartype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "setting": {"key": "setting", "type": "ApprovalSettings"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - setting: Optional["_models.ApprovalSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :keyword setting: The approval setting. - :paramtype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyApprovalRule" - self.setting = setting - - -class RoleManagementPolicyAssignment(_serialization.Model): - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :ivar scope: The role management policy scope. - :vartype scope: str - :ivar role_definition_id: The role definition of management policy assignment. - :vartype role_definition_id: str - :ivar policy_id: The policy id role management policy assignment. - :vartype policy_id: str - :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. - :vartype policy_assignment_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "policy_assignment_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "policy_id": {"key": "properties.policyId", "type": "str"}, - "policy_assignment_properties": { - "key": "properties.policyAssignmentProperties", - "type": "PolicyAssignmentProperties", - }, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - role_definition_id: Optional[str] = None, - policy_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: The role management policy scope. - :paramtype scope: str - :keyword role_definition_id: The role definition of management policy assignment. - :paramtype role_definition_id: str - :keyword policy_id: The policy id role management policy assignment. - :paramtype policy_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = scope - self.role_definition_id = role_definition_id - self.policy_id = policy_id - self.policy_assignment_properties = None - - -class RoleManagementPolicyAssignmentListResult(_serialization.Model): - """Role management policy assignment list operation result. - - :ivar value: Role management policy assignment list. - :vartype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleManagementPolicyAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleManagementPolicyAssignment"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role management policy assignment list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy authentication context rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :ivar is_enabled: The value indicating if rule is enabled. - :vartype is_enabled: bool - :ivar claim_value: The claim value. - :vartype claim_value: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "claim_value": {"key": "claimValue", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_enabled: Optional[bool] = None, - claim_value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :keyword is_enabled: The value indicating if rule is enabled. - :paramtype is_enabled: bool - :keyword claim_value: The claim value. - :paramtype claim_value: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" - self.is_enabled = is_enabled - self.claim_value = claim_value - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :ivar enabled_rules: The list of enabled rules. - :vartype enabled_rules: list[str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "enabled_rules": {"key": "enabledRules", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :keyword enabled_rules: The list of enabled rules. - :paramtype enabled_rules: list[str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyEnablementRule" - self.enabled_rules = enabled_rules - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy expiration rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :ivar is_expiration_required: The value indicating whether expiration is required. - :vartype is_expiration_required: bool - :ivar maximum_duration: The maximum duration of expiration in timespan. - :vartype maximum_duration: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, - "maximum_duration": {"key": "maximumDuration", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_expiration_required: Optional[bool] = None, - maximum_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :keyword is_expiration_required: The value indicating whether expiration is required. - :paramtype is_expiration_required: bool - :keyword maximum_duration: The maximum duration of expiration in timespan. - :paramtype maximum_duration: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyExpirationRule" - self.is_expiration_required = is_expiration_required - self.maximum_duration = maximum_duration - - -class RoleManagementPolicyListResult(_serialization.Model): - """Role management policy list operation result. - - :ivar value: Role management policy list. - :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleManagementPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleManagementPolicy"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role management policy list. - :paramtype value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy notification rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :ivar notification_type: The type of notification. "Email" - :vartype notification_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :ivar notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :vartype notification_level: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :vartype recipient_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :ivar notification_recipients: The list of notification recipients. - :vartype notification_recipients: list[str] - :ivar is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :vartype is_default_recipients_enabled: bool - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "notification_type": {"key": "notificationType", "type": "str"}, - "notification_level": {"key": "notificationLevel", "type": "str"}, - "recipient_type": {"key": "recipientType", "type": "str"}, - "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, - "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, - notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, - recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, - notification_recipients: Optional[List[str]] = None, - is_default_recipients_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :keyword notification_type: The type of notification. "Email" - :paramtype notification_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :keyword notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :paramtype notification_level: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :paramtype recipient_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :keyword notification_recipients: The list of notification recipients. - :paramtype notification_recipients: list[str] - :keyword is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :paramtype is_default_recipients_enabled: bool - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyNotificationRule" - self.notification_type = notification_type - self.notification_level = notification_level - self.recipient_type = recipient_type - self.notification_recipients = notification_recipients - self.is_default_recipients_enabled = is_default_recipients_enabled - - -class RoleManagementPolicyRuleTarget(_serialization.Model): - """The role management policy rule target. - - :ivar caller: The caller of the setting. - :vartype caller: str - :ivar operations: The type of operation. - :vartype operations: list[str] - :ivar level: The assignment level to which rule is applied. - :vartype level: str - :ivar target_objects: The list of target objects. - :vartype target_objects: list[str] - :ivar inheritable_settings: The list of inheritable settings. - :vartype inheritable_settings: list[str] - :ivar enforced_settings: The list of enforced settings. - :vartype enforced_settings: list[str] - """ - - _attribute_map = { - "caller": {"key": "caller", "type": "str"}, - "operations": {"key": "operations", "type": "[str]"}, - "level": {"key": "level", "type": "str"}, - "target_objects": {"key": "targetObjects", "type": "[str]"}, - "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, - "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, - } - - def __init__( - self, - *, - caller: Optional[str] = None, - operations: Optional[List[str]] = None, - level: Optional[str] = None, - target_objects: Optional[List[str]] = None, - inheritable_settings: Optional[List[str]] = None, - enforced_settings: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword caller: The caller of the setting. - :paramtype caller: str - :keyword operations: The type of operation. - :paramtype operations: list[str] - :keyword level: The assignment level to which rule is applied. - :paramtype level: str - :keyword target_objects: The list of target objects. - :paramtype target_objects: list[str] - :keyword inheritable_settings: The list of inheritable settings. - :paramtype inheritable_settings: list[str] - :keyword enforced_settings: The list of enforced settings. - :paramtype enforced_settings: list[str] - """ - super().__init__(**kwargs) - self.caller = caller - self.operations = operations - self.level = level - self.target_objects = target_objects - self.inheritable_settings = inheritable_settings - self.enforced_settings = enforced_settings - - -class UserSet(_serialization.Model): - """The detail of a user. - - :ivar user_type: The type of user. Known values are: "User" and "Group". - :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :ivar is_backup: The value indicating whether the user is a backup fallback approver. - :vartype is_backup: bool - :ivar id: The object id of the user. - :vartype id: str - :ivar description: The description of the user. - :vartype description: str - """ - - _attribute_map = { - "user_type": {"key": "userType", "type": "str"}, - "is_backup": {"key": "isBackup", "type": "bool"}, - "id": {"key": "id", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - user_type: Optional[Union[str, "_models.UserType"]] = None, - is_backup: Optional[bool] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_type: The type of user. Known values are: "User" and "Group". - :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :keyword is_backup: The value indicating whether the user is a backup fallback approver. - :paramtype is_backup: bool - :keyword id: The object id of the user. - :paramtype id: str - :keyword description: The description of the user. - :paramtype description: str - """ - super().__init__(**kwargs) - self.user_type = user_type - self.is_backup = is_backup - self.id = id - self.description = description - - -class ValidationResponse(_serialization.Model): - """Validation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_valid: Whether or not validation succeeded. - :vartype is_valid: bool - :ivar error_info: Failed validation result details. - :vartype error_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo - """ - - _validation = { - "is_valid": {"readonly": True}, - } - - _attribute_map = { - "is_valid": {"key": "isValid", "type": "bool"}, - "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, - } - - def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: - """ - :keyword error_info: Failed validation result details. - :paramtype error_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo - """ - super().__init__(**kwargs) - self.is_valid = None - self.error_info = error_info - - -class ValidationResponseErrorInfo(_serialization.Model): - """Failed validation result details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code indicating why validation failed. - :vartype code: str - :ivar message: Message indicating why validation failed. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/__init__.py deleted file mode 100644 index c2480d05193e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignments_operations import RoleAssignmentsOperations -from ._eligible_child_resources_operations import EligibleChildResourcesOperations -from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations -from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations -from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations -from ._role_management_policies_operations import RoleManagementPoliciesOperations -from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentsOperations", - "EligibleChildResourcesOperations", - "RoleAssignmentSchedulesOperations", - "RoleAssignmentScheduleInstancesOperations", - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilitySchedulesOperations", - "RoleEligibilityScheduleInstancesOperations", - "RoleEligibilityScheduleRequestsOperations", - "RoleManagementPoliciesOperations", - "RoleManagementPolicyAssignmentsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py deleted file mode 100644 index 0de809492db8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py +++ /dev/null @@ -1,175 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/eligibleChildResources") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class EligibleChildResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`eligible_child_resources` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EligibleChildResource"]: - """Get the child resources of a resource on which user has eligible access. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param 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'. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EligibleChildResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_get_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py deleted file mode 100644 index 4df4b3d9601e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleInstanceName": _SERIALIZER.url( - "role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentScheduleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentScheduleInstance"]: - """Gets role assignment schedule instances of a role assignment schedule. - - :param scope: The scope of the role assignment schedule. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} - - @distributed_trace - def get( - self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleInstance: - """Gets the specified role assignment schedule instance. - - :param scope: The scope of the role assignments schedules. Required. - :type scope: str - :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the - role assignment schedule to get. Required. - :type role_assignment_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py deleted file mode 100644 index a6c978ce2b2f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_create_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def get( - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Get the specified role assignment schedule request. - - :param scope: The scope of the role assignment schedule request. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule - request to get. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentScheduleRequest"]: - """Gets role assignment schedule requests for a scope. - - :param scope: The scope of the role assignments schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role assignment schedule request. - - :param scope: The scope of the role assignment request to cancel. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - cancel. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py deleted file mode 100644 index d48d9d282408..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py +++ /dev/null @@ -1,272 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleName": _SERIALIZER.url( - "role_assignment_schedule_name", role_assignment_schedule_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentSchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> _models.RoleAssignmentSchedule: - """Get the specified role assignment schedule for a resource scope. - - :param scope: The scope of the role assignment schedule. Required. - :type scope: str - :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. - Required. - :type role_assignment_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentSchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_name=role_assignment_schedule_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentSchedule"]: - """Gets role assignment schedules for a resource scope. - - :param scope: The scope of the role assignments schedules. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentSchedule or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py deleted file mode 100644 index 98836d3722c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py +++ /dev/null @@ -1,1719 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_subscription_request( - subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - resource_type: str, - resource_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request( - scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request( - role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if tenant_id is not None: - _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleAssignmentId}/validate") - path_format_arguments = { - "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_subscription( - self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List all role assignments that apply to a subscription. - - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_subscription_request( - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource_group( - self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List all role assignments that apply to a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - resource_type: str, - resource_name: str, - filter: Optional[str] = None, - tenant_id: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List all role assignments that apply to a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param resource_type: The resource type name. For example the type name of a web app is 'sites' - (from Microsoft.Web/sites). Required. - :type resource_type: str - :param resource_name: The resource name. Required. - :type resource_name: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" - } - - @distributed_trace - def get( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @distributed_trace - def delete( - self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_assignment_name=role_assignment_name, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} - - @overload - def validate( - self, - scope: str, - role_assignment_name: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate( - self, - scope: str, - role_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate( - self, - scope: str, - role_assignment_name: str, - parameters: Union[_models.RoleAssignmentCreateParameters, IO], - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by scope and name. - - :param 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}'. - Required. - :type scope: str - :param role_assignment_name: The name of the role assignment. It can be any valid GUID. - Required. - :type role_assignment_name: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_validate_request( - scope=scope, - role_assignment_name=role_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignment"]: - """List all role assignments that apply to a scope. - - :param 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}'. - Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignment or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} - - @distributed_trace - def get_by_id( - self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> _models.RoleAssignment: - """Get a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_assignment_id=role_assignment_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - def create_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.RoleAssignment: - """Create or update a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_create_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - create_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @distributed_trace - def delete_by_id( - self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.RoleAssignment]: - """Delete a role assignment by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. Default value is None. - :type tenant_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignment or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - role_assignment_id=role_assignment_id, - tenant_id=tenant_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete_by_id.metadata = {"url": "/{roleAssignmentId}"} - - @overload - def validate_by_id( - self, - role_assignment_id: str, - parameters: _models.RoleAssignmentCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_by_id( - self, role_assignment_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_by_id( - self, role_assignment_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any - ) -> _models.ValidationResponse: - """Validate a role assignment create or update operation by ID. - - :param role_assignment_id: The fully qualified ID of the role assignment including scope, - resource name, and resource type. Format: - /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: - /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. - Required. - :type role_assignment_id: str - :param parameters: Parameters for the role assignment. Is either a - RoleAssignmentCreateParameters type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ValidationResponse or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") - - request = build_validate_by_id_request( - role_assignment_id=role_assignment_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidationResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate_by_id.metadata = {"url": "/{roleAssignmentId}/validate"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py deleted file mode 100644 index 462d376f9d30..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleInstanceName": _SERIALIZER.url( - "role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleEligibilityScheduleInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilityScheduleInstance"]: - """Gets role eligibility schedule instances of a role eligibility schedule. - - :param scope: The scope of the role eligibility schedule. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} - - @distributed_trace - def get( - self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleInstance: - """Gets the specified role eligibility schedule instance. - - :param scope: The scope of the role eligibility schedules. Required. - :type scope: str - :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the - role eligibility schedule to get. Required. - :type role_eligibility_schedule_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py deleted file mode 100644 index 179ab436ba63..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleEligibilityScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_create_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def get( - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Get the specified role eligibility schedule request. - - :param scope: The scope of the role eligibility schedule request. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule - request to get. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilityScheduleRequest"]: - """Gets role eligibility schedule requests for a scope. - - :param scope: The scope of the role eligibility schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role eligibility schedule request. - - :param scope: The scope of the role eligibility request to cancel. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - cancel. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py deleted file mode 100644 index f7b2e7ba2fa6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py +++ /dev/null @@ -1,272 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleName": _SERIALIZER.url( - "role_eligibility_schedule_name", role_eligibility_schedule_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleEligibilitySchedulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> _models.RoleEligibilitySchedule: - """Get the specified role eligibility schedule for a resource scope. - - :param scope: The scope of the role eligibility schedule. Required. - :type scope: str - :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. - Required. - :type role_eligibility_schedule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilitySchedule or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_name=role_eligibility_schedule_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilitySchedule"]: - """Gets role eligibility schedules for a resource scope. - - :param scope: The scope of the role eligibility schedules. Required. - :type scope: str - :param 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. - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilitySchedule or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py deleted file mode 100644 index 95f8a85ac085..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py +++ /dev/null @@ -1,520 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleManagementPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_management_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: - """Get the specified role management policy for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to get. - Required. - :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @overload - def update( - self, - scope: str, - role_management_policy_name: str, - parameters: _models.RoleManagementPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - scope: str, - role_management_policy_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - scope: str, - role_management_policy_name: str, - parameters: Union[_models.RoleManagementPolicy, IO], - **kwargs: Any - ) -> _models.RoleManagementPolicy: - """Update a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy - type or a IO type. Required. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicy or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleManagementPolicy") - - request = build_update_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_name: str, **kwargs: Any - ) -> None: - """Delete a role management policy. - - :param scope: The scope of the role management policy to upsert. Required. - :type scope: str - :param role_management_policy_name: The name (guid) of the role management policy to upsert. - Required. - :type role_management_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_management_policy_name=role_management_policy_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" - } - - @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: - """Gets role management policies for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicy or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py deleted file mode 100644 index 2a9a210e7a20..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py +++ /dev/null @@ -1,532 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyAssignmentName": _SERIALIZER.url( - "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyAssignmentName": _SERIALIZER.url( - "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleManagementPolicyAssignmentName": _SERIALIZER.url( - "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleManagementPolicyAssignmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s - :attr:`role_management_policy_assignments` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get( - self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Get the specified role management policy assignment for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to get. Required. - :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @overload - def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: _models.RoleManagementPolicyAssignment, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_management_policy_assignment_name: str, - parameters: Union[_models.RoleManagementPolicyAssignment, IO], - **kwargs: Any - ) -> _models.RoleManagementPolicyAssignment: - """Create a role management policy assignment. - - :param scope: The scope of the role management policy assignment to upsert. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to upsert. Required. - :type role_management_policy_assignment_name: str - :param parameters: Parameters for the role management policy assignment. Is either a - RoleManagementPolicyAssignment type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleManagementPolicyAssignment or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") - - request = build_create_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any - ) -> None: - """Delete a role management policy assignment. - - :param scope: The scope of the role management policy assignment to delete. Required. - :type scope: str - :param role_management_policy_assignment_name: The name of format {guid_guid} the role - management policy assignment to delete. Required. - :type role_management_policy_assignment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_management_policy_assignment_name=role_management_policy_assignment_name, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" - } - - @distributed_trace - def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: - """Gets role management assignment policies for a resource scope. - - :param scope: The scope of the role management policy. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") - ) - cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py deleted file mode 100644 index 6fe9e6b5e358..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,129 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - Operations, - RoleAssignmentApprovalOperations, - RoleAssignmentApprovalStepOperations, - RoleAssignmentApprovalStepsOperations, - ScopeRoleAssignmentApprovalOperations, - ScopeRoleAssignmentApprovalStepOperations, - ScopeRoleAssignmentApprovalStepsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Request Approvals service provides the workflow for running request approvals on different kind - of resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.operations.Operations - :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations - :vartype role_assignment_approval: - azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalOperations - :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations - :vartype role_assignment_approval_steps: - azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepsOperations - :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations - :vartype role_assignment_approval_step: - azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepOperations - :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations - :vartype scope_role_assignment_approval: - azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalOperations - :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations - operations - :vartype scope_role_assignment_approval_steps: - azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepsOperations - :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations - :vartype scope_role_assignment_approval_step: - azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py deleted file mode 100644 index 6dd3f3d72079..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json deleted file mode 100644 index c964b3aa4069..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "chosen_version": "2021-01-01-preview", - "total_api_version_list": ["2021-01-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Request Approvals service provides the workflow for running request approvals on different kind of resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "role_assignment_approval": "RoleAssignmentApprovalOperations", - "role_assignment_approval_steps": "RoleAssignmentApprovalStepsOperations", - "role_assignment_approval_step": "RoleAssignmentApprovalStepOperations", - "scope_role_assignment_approval": "ScopeRoleAssignmentApprovalOperations", - "scope_role_assignment_approval_steps": "ScopeRoleAssignmentApprovalStepsOperations", - "scope_role_assignment_approval_step": "ScopeRoleAssignmentApprovalStepOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 26d5b0b18a30..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,129 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - Operations, - RoleAssignmentApprovalOperations, - RoleAssignmentApprovalStepOperations, - RoleAssignmentApprovalStepsOperations, - ScopeRoleAssignmentApprovalOperations, - ScopeRoleAssignmentApprovalStepOperations, - ScopeRoleAssignmentApprovalStepsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Request Approvals service provides the workflow for running request approvals on different kind - of resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations - :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations - :vartype role_assignment_approval: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations - :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations - :vartype role_assignment_approval_steps: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations - :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations - :vartype role_assignment_approval_step: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations - :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations - :vartype scope_role_assignment_approval: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations - :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations - operations - :vartype scope_role_assignment_approval_steps: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations - :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations - :vartype scope_role_assignment_approval_step: - azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-01-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py deleted file mode 100644 index d9c6a3b71eb0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-01-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/__init__.py deleted file mode 100644 index 1349e3f13a6f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._role_assignment_approval_operations import RoleAssignmentApprovalOperations -from ._role_assignment_approval_steps_operations import RoleAssignmentApprovalStepsOperations -from ._role_assignment_approval_step_operations import RoleAssignmentApprovalStepOperations -from ._scope_role_assignment_approval_operations import ScopeRoleAssignmentApprovalOperations -from ._scope_role_assignment_approval_steps_operations import ScopeRoleAssignmentApprovalStepsOperations -from ._scope_role_assignment_approval_step_operations import ScopeRoleAssignmentApprovalStepOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "RoleAssignmentApprovalOperations", - "RoleAssignmentApprovalStepsOperations", - "RoleAssignmentApprovalStepOperations", - "ScopeRoleAssignmentApprovalOperations", - "ScopeRoleAssignmentApprovalStepsOperations", - "ScopeRoleAssignmentApprovalStepOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py deleted file mode 100644 index 21203e527e40..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py deleted file mode 100644 index ef6aede4d8f1..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py +++ /dev/null @@ -1,207 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_approval_operations import build_get_by_id_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleAssignmentApproval"]: - """Get role assignment approvals. - - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is - performed. If $filter=asApprover() is provided, the returned list only includes all role - assignment approvals that the calling user is assigned as an approver for. If - $filter=asCreatedBy() is provided, the returned list only includes all role assignment - approvals that the calling user created requests for. If $filter=asTarget() is provided, the - returned list only includes all role assignment approvals that the calling user has requests - targeted for. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApproval or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} - - @distributed_trace_async - async def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApproval or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py deleted file mode 100644 index 911e15f5a852..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py +++ /dev/null @@ -1,390 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_approval_step_operations import ( - build_get_by_id_request, - build_patch_request, - build_put_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentApprovalStepOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_approval_step` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - async def patch( - self, - approval_id: str, - stage_id: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def patch( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def patch( - self, - approval_id: str, - stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_patch_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} - - @overload - async def put( - self, - approval_id: str, - stage_id: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, - approval_id: str, - stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_put_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py deleted file mode 100644 index 9ddcbca25087..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py +++ /dev/null @@ -1,111 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_approval_steps_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentApprovalStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_approval_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStepListResult or the result of cls(response) - :rtype: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - - request = build_list_request( - approval_id=approval_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py deleted file mode 100644 index 06e5aeb7e332..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py +++ /dev/null @@ -1,215 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scope_role_assignment_approval_operations import build_get_by_id_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScopeRoleAssignmentApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentApproval"]: - """Get role assignment approvals. - - :param scope: The scope of the resource. Required. - :type scope: str - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is - performed. If $filter=asApprover() is provided, the returned list only includes all role - assignment approvals that the calling user is assigned as an approver for. If - $filter=asCreatedBy() is provided, the returned list only includes all role assignment - approvals that the calling user created requests for. If $filter=asTarget() is provided, the - returned list only includes all role assignment approvals that the calling user has requests - targeted for. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApproval or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} - - @distributed_trace_async - async def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApproval or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - scope=scope, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py deleted file mode 100644 index c45868f6f320..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py +++ /dev/null @@ -1,431 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scope_role_assignment_approval_step_operations import ( - build_get_by_id_request, - build_patch_request, - build_put_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScopeRoleAssignmentApprovalStepOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval_step` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get_by_id( - self, approval_id: str, stage_id: str, scope: str, **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - async def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_patch_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - async def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_put_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py deleted file mode 100644 index bcf5c7229157..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py +++ /dev/null @@ -1,114 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._scope_role_assignment_approval_steps_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ScopeRoleAssignmentApprovalStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.aio.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStepListResult or the result of cls(response) - :rtype: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - - request = build_list_request( - approval_id=approval_id, - scope=scope, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py deleted file mode 100644 index 939a734a9b72..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorDefinitionProperties -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import RoleAssignmentApproval -from ._models_py3 import RoleAssignmentApprovalListResult -from ._models_py3 import RoleAssignmentApprovalStep -from ._models_py3 import RoleAssignmentApprovalStepListResult -from ._models_py3 import RoleAssignmentApprovalStepProperties - -from ._authorization_management_client_enums import RoleAssignmentApprovalActorIdentityType -from ._authorization_management_client_enums import RoleAssignmentApprovalStepReviewResult -from ._authorization_management_client_enums import RoleAssignmentApprovalStepStatus -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ErrorDefinition", - "ErrorDefinitionProperties", - "Operation", - "OperationDisplay", - "OperationListResult", - "RoleAssignmentApproval", - "RoleAssignmentApprovalListResult", - "RoleAssignmentApprovalStep", - "RoleAssignmentApprovalStepListResult", - "RoleAssignmentApprovalStepProperties", - "RoleAssignmentApprovalActorIdentityType", - "RoleAssignmentApprovalStepReviewResult", - "RoleAssignmentApprovalStepStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index 74ba291f3bcc..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class RoleAssignmentApprovalActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class RoleAssignmentApprovalStepReviewResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The decision on the approval stage. This value is initially set to NotReviewed. Approvers can - take action of Approve/Deny. - """ - - APPROVE = "Approve" - DENY = "Deny" - NOT_REVIEWED = "NotReviewed" - - -class RoleAssignmentApprovalStepStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an approval.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - EXPIRED = "Expired" - INITIALIZING = "Initializing" - ESCALATING = "Escalating" - COMPLETING = "Completing" - ESCALATED = "Escalated" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py deleted file mode 100644 index ee0554ffecee..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py +++ /dev/null @@ -1,480 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ErrorDefinition(_serialization.Model): - """Error description and code explaining why an operation failed. - - :ivar error: Error of the list gateway status. - :vartype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionProperties"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error of the list gateway status. - :paramtype error: - ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorDefinitionProperties(_serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :ivar code: Error code of list gateway. - :vartype code: str - """ - - _validation = { - "message": {"readonly": True}, - } - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code of list gateway. - :paramtype code: str - """ - super().__init__(**kwargs) - self.message = None - self.code = code - - -class Operation(_serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :ivar name: Name of the operation. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :ivar origin: Origin of the operation. Values include user|system|user,system. - :vartype origin: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation. - :paramtype name: str - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :keyword origin: Origin of the operation. Values include user|system|user,system. - :paramtype origin: str - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - - -class OperationDisplay(_serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection value. - :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :keyword next_link: The URI that can be used to request the next set of paged results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentApproval(_serialization.Model): - """Role Assignment Approval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment approval id. - :vartype id: str - :ivar name: The role assignment approval unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar stages: This is the collection of stages returned when one does an expand on it. - :vartype stages: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "stages": {"key": "properties.stages", "type": "[RoleAssignmentApprovalStep]"}, - } - - def __init__(self, *, stages: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: - """ - :keyword stages: This is the collection of stages returned when one does an expand on it. - :paramtype stages: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.stages = stages - - -class RoleAssignmentApprovalListResult(_serialization.Model): - """List of role assignment approvals. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Role Assignment Approval list. - :vartype value: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentApproval]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.RoleAssignmentApproval"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Role Assignment Approval list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RoleAssignmentApprovalStep(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role assignment approval stage properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment approval stage id. - :vartype id: str - :ivar name: The role assignment approval stage name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the approval stage. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an approval. Known values are: - "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", - and "Escalated". - :vartype status: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus - :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. - :vartype assigned_to_me: bool - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - and "NotReviewed". - :vartype review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "assigned_to_me": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "assigned_to_me": {"key": "properties.assignedToMe", "type": "bool"}, - "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, - "review_result": {"key": "properties.reviewResult", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, - "principal_type": {"key": "properties.reviewedBy.principalType", "type": "str"}, - "principal_name": {"key": "properties.reviewedBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.reviewedBy.userPrincipalName", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the approval stage. - :paramtype display_name: str - :keyword review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - and "NotReviewed". - :paramtype review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = review_result - self.justification = justification - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class RoleAssignmentApprovalStepListResult(_serialization.Model): - """List of role assignment approval stage list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Role Assignment Approval Step list. - :vartype value: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentApprovalStep]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.RoleAssignmentApprovalStep"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Role Assignment Approval Step list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RoleAssignmentApprovalStepProperties(_serialization.Model): - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the approval stage. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an approval. Known values are: - "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", - and "Escalated". - :vartype status: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus - :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. - :vartype assigned_to_me: bool - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - and "NotReviewed". - :vartype review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "status": {"readonly": True}, - "assigned_to_me": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "assigned_to_me": {"key": "assignedToMe", "type": "bool"}, - "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, - "review_result": {"key": "reviewResult", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - "principal_id": {"key": "reviewedBy.principalId", "type": "str"}, - "principal_type": {"key": "reviewedBy.principalType", "type": "str"}, - "principal_name": {"key": "reviewedBy.principalName", "type": "str"}, - "user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - review_result: Optional[Union[str, "_models.RoleAssignmentApprovalStepReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the approval stage. - :paramtype display_name: str - :keyword review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - and "NotReviewed". - :paramtype review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = review_result - self.justification = justification - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/__init__.py deleted file mode 100644 index 1349e3f13a6f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._role_assignment_approval_operations import RoleAssignmentApprovalOperations -from ._role_assignment_approval_steps_operations import RoleAssignmentApprovalStepsOperations -from ._role_assignment_approval_step_operations import RoleAssignmentApprovalStepOperations -from ._scope_role_assignment_approval_operations import ScopeRoleAssignmentApprovalOperations -from ._scope_role_assignment_approval_steps_operations import ScopeRoleAssignmentApprovalStepsOperations -from ._scope_role_assignment_approval_step_operations import ScopeRoleAssignmentApprovalStepOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "RoleAssignmentApprovalOperations", - "RoleAssignmentApprovalStepsOperations", - "RoleAssignmentApprovalStepOperations", - "ScopeRoleAssignmentApprovalOperations", - "ScopeRoleAssignmentApprovalStepsOperations", - "ScopeRoleAssignmentApprovalStepOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py deleted file mode 100644 index 548e4758bdcc..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py deleted file mode 100644 index 44572006418a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py +++ /dev/null @@ -1,254 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(approval_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleAssignmentApproval"]: - """Get role assignment approvals. - - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is - performed. If $filter=asApprover() is provided, the returned list only includes all role - assignment approvals that the calling user is assigned as an approver for. If - $filter=asCreatedBy() is provided, the returned list only includes all role assignment - approvals that the calling user created requests for. If $filter=asTarget() is provided, the - returned list only includes all role assignment approvals that the calling user has requests - targeted for. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApproval or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals"} - - @distributed_trace - def get_by_id(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApproval: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApproval or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py deleted file mode 100644 index 4e87856a8042..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py +++ /dev/null @@ -1,476 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_by_id_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(approval_id: str, stage_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentApprovalStepOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_approval_step` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get_by_id(self, approval_id: str, stage_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStep: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - def patch( - self, - approval_id: str, - stage_id: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def patch( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def patch( - self, - approval_id: str, - stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_patch_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} - - @overload - def put( - self, - approval_id: str, - stage_id: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, approval_id: str, stage_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, - approval_id: str, - stage_id: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_put_request( - approval_id=approval_id, - stage_id=stage_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py deleted file mode 100644 index 212d0864a22d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(approval_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages") - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentApprovalStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_approval_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, approval_id: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStepListResult or the result of cls(response) - :rtype: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - - request = build_list_request( - approval_id=approval_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py deleted file mode 100644 index 9fba479aa086..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py +++ /dev/null @@ -1,268 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScopeRoleAssignmentApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentApproval"]: - """Get role assignment approvals. - - :param scope: The scope of the resource. Required. - :type scope: str - :param filter: The filter to apply on the operation. Valid values for $filter are: - 'asApprover()', 'asCreatedBy()' and 'asTarget()'. If $filter is not provided, no filtering is - performed. If $filter=asApprover() is provided, the returned list only includes all role - assignment approvals that the calling user is assigned as an approver for. If - $filter=asCreatedBy() is provided, the returned list only includes all role assignment - approvals that the calling user created requests for. If $filter=asTarget() is provided, the - returned list only includes all role assignment approvals that the calling user has requests - targeted for. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApproval or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} - - @distributed_trace - def get_by_id(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApproval: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApproval or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApproval] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - scope=scope, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApproval", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py deleted file mode 100644 index 6b602185504e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py +++ /dev/null @@ -1,523 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_by_id_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(approval_id: str, stage_id: str, scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "stageId": _SERIALIZER.url("stage_id", stage_id, "str"), - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScopeRoleAssignmentApprovalStepOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval_step` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get_by_id( - self, approval_id: str, stage_id: str, scope: str, **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def patch( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to patch. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_patch_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } - - @overload - def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: _models.RoleAssignmentApprovalStepProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, - approval_id: str, - stage_id: str, - scope: str, - properties: Union[_models.RoleAssignmentApprovalStepProperties, IO], - **kwargs: Any - ) -> _models.RoleAssignmentApprovalStep: - """Record a decision. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param stage_id: The id of the role assignment approval stage. Required. - :type stage_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :param properties: Role Assignment Approval stage properties to put. Is either a - RoleAssignmentApprovalStepProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStep or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentApprovalStep] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "RoleAssignmentApprovalStepProperties") - - request = build_put_request( - approval_id=approval_id, - stage_id=stage_id, - scope=scope, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStep", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py deleted file mode 100644 index 9300cb8ffd34..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py +++ /dev/null @@ -1,144 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(approval_id: str, scope: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages" - ) # pylint: disable=line-too-long - path_format_arguments = { - "approvalId": _SERIALIZER.url("approval_id", approval_id, "str"), - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ScopeRoleAssignmentApprovalStepsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_01_01_preview.AuthorizationManagementClient`'s - :attr:`scope_role_assignment_approval_steps` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, approval_id: str, scope: str, **kwargs: Any) -> _models.RoleAssignmentApprovalStepListResult: - """Get role assignment approval. - - :param approval_id: The id of the role assignment approval. Required. - :type approval_id: str - :param scope: The scope of the resource. Required. - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentApprovalStepListResult or the result of cls(response) - :rtype: - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-01-01-preview") - ) - cls: ClsType[_models.RoleAssignmentApprovalStepListResult] = kwargs.pop("cls", None) - - request = build_list_request( - approval_id=approval_id, - scope=scope, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentApprovalStepListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py deleted file mode 100644 index 3da89379d0a1..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_03_01_preview.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceMyDecisionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py deleted file mode 100644 index 6c0ba0427f19..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json deleted file mode 100644 index 9b441250f678..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "chosen_version": "2021-03-01-preview", - "total_api_version_list": ["2021-03-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "access_review_schedule_definitions": "AccessReviewScheduleDefinitionsOperations", - "access_review_instances": "AccessReviewInstancesOperations", - "access_review_instance": "AccessReviewInstanceOperations", - "access_review_instance_decisions": "AccessReviewInstanceDecisionsOperations", - "access_review_default_settings": "AccessReviewDefaultSettingsOperations", - "access_review_schedule_definitions_assigned_for_my_approval": "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "access_review_instances_assigned_for_my_approval": "AccessReviewInstancesAssignedForMyApprovalOperations", - "access_review_instance_my_decisions": "AccessReviewInstanceMyDecisionsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index ca6a9fc4c3b0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-03-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py deleted file mode 100644 index fbaad4d60844..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-03-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/__init__.py deleted file mode 100644 index 0bb9a6bebd04..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py deleted file mode 100644 index aa90875c9933..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_default_settings_operations import build_get_request, build_put_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - async def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index 2ea6cc3f2d42..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,155 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_decisions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index 324318fbaa75..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,218 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_assigned_for_my_approval_operations import ( - build_get_by_id_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py deleted file mode 100644 index 4092d7620e33..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,217 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_operations import build_get_by_id_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index 8b866369d874..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,146 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py deleted file mode 100644 index c5e060119af7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AccessReviewDecision -from ._models_py3 import AccessReviewDecisionIdentity -from ._models_py3 import AccessReviewDecisionListResult -from ._models_py3 import AccessReviewDecisionProperties -from ._models_py3 import AccessReviewDecisionResource -from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity -from ._models_py3 import AccessReviewDecisionUserIdentity -from ._models_py3 import AccessReviewDefaultSettings -from ._models_py3 import AccessReviewInstance -from ._models_py3 import AccessReviewInstanceListResult -from ._models_py3 import AccessReviewReviewer -from ._models_py3 import AccessReviewScheduleDefinition -from ._models_py3 import AccessReviewScheduleDefinitionListResult -from ._models_py3 import AccessReviewScheduleDefinitionProperties -from ._models_py3 import AccessReviewScheduleSettings -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorDefinitionProperties -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult - -from ._authorization_management_client_enums import AccessRecommendationType -from ._authorization_management_client_enums import AccessReviewActorIdentityType -from ._authorization_management_client_enums import AccessReviewApplyResult -from ._authorization_management_client_enums import AccessReviewInstanceStatus -from ._authorization_management_client_enums import AccessReviewRecurrencePatternType -from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType -from ._authorization_management_client_enums import AccessReviewResult -from ._authorization_management_client_enums import AccessReviewReviewerType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus -from ._authorization_management_client_enums import AccessReviewScopeAssignmentState -from ._authorization_management_client_enums import AccessReviewScopePrincipalType -from ._authorization_management_client_enums import DecisionResourceType -from ._authorization_management_client_enums import DecisionTargetType -from ._authorization_management_client_enums import DefaultDecisionType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessReviewDecision", - "AccessReviewDecisionIdentity", - "AccessReviewDecisionListResult", - "AccessReviewDecisionProperties", - "AccessReviewDecisionResource", - "AccessReviewDecisionServicePrincipalIdentity", - "AccessReviewDecisionUserIdentity", - "AccessReviewDefaultSettings", - "AccessReviewInstance", - "AccessReviewInstanceListResult", - "AccessReviewReviewer", - "AccessReviewScheduleDefinition", - "AccessReviewScheduleDefinitionListResult", - "AccessReviewScheduleDefinitionProperties", - "AccessReviewScheduleSettings", - "ErrorDefinition", - "ErrorDefinitionProperties", - "Operation", - "OperationDisplay", - "OperationListResult", - "AccessRecommendationType", - "AccessReviewActorIdentityType", - "AccessReviewApplyResult", - "AccessReviewInstanceStatus", - "AccessReviewRecurrencePatternType", - "AccessReviewRecurrenceRangeType", - "AccessReviewResult", - "AccessReviewReviewerType", - "AccessReviewScheduleDefinitionReviewersType", - "AccessReviewScheduleDefinitionStatus", - "AccessReviewScopeAssignmentState", - "AccessReviewScopePrincipalType", - "DecisionResourceType", - "DecisionTargetType", - "DefaultDecisionType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index a98d78c0b730..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessRecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The feature- generated recommendation shown to the reviewer.""" - - APPROVE = "Approve" - DENY = "Deny" - NO_INFO_AVAILABLE = "NoInfoAvailable" - - -class AccessReviewActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewApplyResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The outcome of applying the decision.""" - - NEW = "New" - APPLYING = "Applying" - APPLIED_SUCCESSFULLY = "AppliedSuccessfully" - APPLIED_WITH_UNKNOWN_FAILURE = "AppliedWithUnknownFailure" - APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" - APPLY_NOT_SUPPORTED = "ApplyNotSupported" - - -class AccessReviewInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an access review instance.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewRecurrencePatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence type : weekly, monthly, etc.""" - - WEEKLY = "weekly" - ABSOLUTE_MONTHLY = "absoluteMonthly" - - -class AccessReviewRecurrenceRangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence range type. The possible values are: endDate, noEnd, numbered.""" - - END_DATE = "endDate" - NO_END = "noEnd" - NUMBERED = "numbered" - - -class AccessReviewResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The decision on the approval step. This value is initially set to NotReviewed. Approvers can - take action of Approve/Deny. - """ - - APPROVE = "Approve" - DENY = "Deny" - NOT_REVIEWED = "NotReviewed" - DONT_KNOW = "DontKnow" - NOT_NOTIFIED = "NotNotified" - - -class AccessReviewReviewerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewScheduleDefinitionReviewersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - ASSIGNED = "Assigned" - SELF = "Self" - MANAGERS = "Managers" - - -class AccessReviewScheduleDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an accessReview.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewScopeAssignmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The role assignment state eligible/active to review.""" - - ELIGIBLE = "eligible" - ACTIVE = "active" - - -class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type user/servicePrincipal to review.""" - - USER = "user" - GUEST_USER = "guestUser" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class DecisionResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of resource.""" - - AZURE_ROLE = "azureRole" - - -class DecisionTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of decision target : User/ServicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This specifies the behavior for the autoReview feature when an access review completes.""" - - APPROVE = "Approve" - DENY = "Deny" - RECOMMENDATION = "Recommendation" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py deleted file mode 100644 index 866793ed7b3b..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1773 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :ivar type_properties_resource_type: The type of resource. "azureRole" - :vartype type_properties_resource_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id_properties_resource_id: The id of resource associated with a decision record. - :vartype id_properties_resource_id: str - :ivar display_name_properties_resource_display_name: The display name of resource associated - with a decision record. - :vartype display_name_properties_resource_display_name: str - :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype type_properties_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id_properties_principal_id: The id of principal whose access was reviewed. - :vartype id_properties_principal_id: str - :ivar display_name_properties_principal_display_name: The display name of the user whose access - was reviewed. - :vartype display_name_properties_principal_display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_properties_applied_by_principal_id": {"readonly": True}, - "principal_type_properties_applied_by_principal_type": {"readonly": True}, - "principal_name_properties_applied_by_principal_name": {"readonly": True}, - "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, - "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, - "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, - "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, - "id_properties_resource_id": {"readonly": True}, - "display_name_properties_resource_display_name": {"readonly": True}, - "id_properties_principal_id": {"readonly": True}, - "display_name_properties_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "recommendation": {"key": "properties.recommendation", "type": "str"}, - "decision": {"key": "properties.decision", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "properties.applyResult", "type": "str"}, - "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, - "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, - "principal_type_properties_applied_by_principal_type": { - "key": "properties.appliedBy.principalType", - "type": "str", - }, - "principal_name_properties_applied_by_principal_name": { - "key": "properties.appliedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_applied_by_user_principal_name": { - "key": "properties.appliedBy.userPrincipalName", - "type": "str", - }, - "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, - "principal_type_properties_reviewed_by_principal_type": { - "key": "properties.reviewedBy.principalType", - "type": "str", - }, - "principal_name_properties_reviewed_by_principal_name": { - "key": "properties.reviewedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_reviewed_by_user_principal_name": { - "key": "properties.reviewedBy.userPrincipalName", - "type": "str", - }, - "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, - "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, - "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, - "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, - "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, - "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_resource_type: Optional[str] = None - self.id_properties_resource_id = None - self.display_name_properties_resource_display_name = None - self.type_properties_principal_type: Optional[str] = None - self.id_properties_principal_id = None - self.display_name_properties_principal_display_name = None - - -class AccessReviewDecisionIdentity(_serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - _subtype_map = { - "type": { - "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", - "user": "AccessReviewDecisionUserIdentity", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id = None - self.display_name = None - - -class AccessReviewDecisionListResult(_serialization.Model): - """List of access review decisions. - - :ivar value: Access Review Decision list. - :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewDecision]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewDecision"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Decision list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :ivar type_resource_type: The type of resource. "azureRole" - :vartype type_resource_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id_resource_id: The id of resource associated with a decision record. - :vartype id_resource_id: str - :ivar display_name_resource_display_name: The display name of resource associated with a - decision record. - :vartype display_name_resource_display_name: str - :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values - are: "user" and "servicePrincipal". - :vartype type_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id_principal_id: The id of principal whose access was reviewed. - :vartype id_principal_id: str - :ivar display_name_principal_display_name: The display name of the user whose access was - reviewed. - :vartype display_name_principal_display_name: str - """ - - _validation = { - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_applied_by_principal_id": {"readonly": True}, - "principal_type_applied_by_principal_type": {"readonly": True}, - "principal_name_applied_by_principal_name": {"readonly": True}, - "user_principal_name_applied_by_user_principal_name": {"readonly": True}, - "principal_id_reviewed_by_principal_id": {"readonly": True}, - "principal_type_reviewed_by_principal_type": {"readonly": True}, - "principal_name_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, - "id_resource_id": {"readonly": True}, - "display_name_resource_display_name": {"readonly": True}, - "id_principal_id": {"readonly": True}, - "display_name_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "recommendation": {"key": "recommendation", "type": "str"}, - "decision": {"key": "decision", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "applyResult", "type": "str"}, - "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, - "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, - "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, - "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, - "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, - "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, - "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, - "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, - "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, - "type_resource_type": {"key": "resource.type", "type": "str"}, - "id_resource_id": {"key": "resource.id", "type": "str"}, - "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, - "type_principal_type": {"key": "principal.type", "type": "str"}, - "id_principal_id": {"key": "principal.id", "type": "str"}, - "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type_resource_type: Optional[str] = None - self.id_resource_id = None - self.display_name_resource_display_name = None - self.type_principal_type: Optional[str] = None - self.id_principal_id = None - self.display_name_principal_display_name = None - - -class AccessReviewDecisionResource(_serialization.Model): - """Target of the decision. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of resource. Required. "azureRole" - :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id: The id of resource associated with a decision record. - :vartype id: str - :ivar display_name: The display name of resource associated with a decision record. - :vartype display_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id = None - self.display_name = None - - -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): - """Service Principal Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "app_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "app_id": {"key": "appId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "servicePrincipal" - self.app_id = None - - -class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): - """User Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "user_principal_name": {"key": "userPrincipalName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "user" - self.user_principal_name = None - - -class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "properties.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, - "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_recurrence_range_type = type_properties_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type - self.interval = interval - - -class AccessReviewInstance(_serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - - -class AccessReviewInstanceListResult(_serialization.Model): - """List of Access Review Instances. - - :ivar value: Access Review Instance list. - :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewReviewer(_serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The id of the reviewer(user/servicePrincipal). - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - "principal_type": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: The id of the reviewer(user/servicePrincipal). - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.principal_type = None - - -class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Known values are: "user", "guestUser", and "servicePrincipal". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_properties_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_properties_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, - "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, - "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, - "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": { - "key": "properties.settings.justificationRequiredOnApproval", - "type": "bool", - }, - "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, - "type_properties_settings_recurrence_range_type": { - "key": "properties.settings.recurrence.range.type", - "type": "str", - }, - "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_settings_recurrence_pattern_type": { - "key": "properties.settings.recurrence.pattern.type", - "type": "str", - }, - "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, - "principal_type_properties_created_by_principal_type": { - "key": "properties.createdBy.principalType", - "type": "str", - }, - "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_settings_recurrence_range_type: Optional[ - Union[str, "_models.AccessReviewRecurrenceRangeType"] - ] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_settings_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The - possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and - "numbered". - :paramtype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, - monthly, etc. Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(_serialization.Model): - """List of Access Review Schedule Definitions. - - :ivar value: Access Review Schedule Definition list. - :vartype value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Schedule Definition list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Known values are: "user", "guestUser", and "servicePrincipal". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known - values are: "weekly" and "absoluteMonthly". - :vartype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, - "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, - "assignment_state": {"key": "scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, - "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, - "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "createdBy.principalId", "type": "str"}, - "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, - "principal_name": {"key": "createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_settings_recurrence_range_type = type_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Settings of an Access Review. - - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :vartype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _attribute_map = { - "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, - "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, - "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, - "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, - "interval": {"key": "recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - instance_duration_in_days: Optional[int] = None, - type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :paramtype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.instance_duration_in_days = instance_duration_in_days - self.type_recurrence_range_type = type_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_recurrence_pattern_type = type_recurrence_pattern_type - self.interval = interval - - -class ErrorDefinition(_serialization.Model): - """Error description and code explaining why an operation failed. - - :ivar error: Error of the list gateway status. - :vartype error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionProperties"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error of the list gateway status. - :paramtype error: - ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorDefinitionProperties(_serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :ivar code: Error code of list gateway. - :vartype code: str - """ - - _validation = { - "message": {"readonly": True}, - } - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code of list gateway. - :paramtype code: str - """ - super().__init__(**kwargs) - self.message = None - self.code = code - - -class Operation(_serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :ivar name: Name of the operation. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :ivar origin: Origin of the operation. - :vartype origin: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation. - :paramtype name: str - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :keyword origin: Origin of the operation. - :paramtype origin: str - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - - -class OperationDisplay(_serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection value. - :paramtype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :keyword next_link: The URI that can be used to request the next set of paged results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/__init__.py deleted file mode 100644 index 0bb9a6bebd04..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py deleted file mode 100644 index d7e6f83d0087..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index d60b6ad2d3e6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index 329036fc2560..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,472 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace - def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py deleted file mode 100644 index 50abda50ab06..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,514 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_stop_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_reset_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_apply_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_send_reminders_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_accept_recommendations_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace - def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace - def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace - def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace - def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index 41ed9c6bc825..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py deleted file mode 100644 index 80a4753c2734..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index 00ed6fdbac0a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,168 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index 101bd78385fb..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,606 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_by_id_request( - schedule_definition_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py deleted file mode 100644 index e59c4f92435e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_03_01_preview.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-03-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py deleted file mode 100644 index f4f80a6b47c8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceContactedReviewersOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_instance_contacted_reviewers: - AccessReviewInstanceContactedReviewersOperations operations - :vartype access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceContactedReviewersOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceMyDecisionsOperations - :ivar tenant_level_access_review_instance_contacted_reviewers: - TenantLevelAccessReviewInstanceContactedReviewersOperations operations - :vartype tenant_level_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_07_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.tenant_level_access_review_instance_contacted_reviewers = ( - TenantLevelAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py deleted file mode 100644 index 95c3a123e29e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json deleted file mode 100644 index c1ad5b13cc4e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "chosen_version": "2021-07-01-preview", - "total_api_version_list": ["2021-07-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "access_review_schedule_definitions": "AccessReviewScheduleDefinitionsOperations", - "access_review_instances": "AccessReviewInstancesOperations", - "access_review_instance": "AccessReviewInstanceOperations", - "access_review_instance_decisions": "AccessReviewInstanceDecisionsOperations", - "access_review_instance_contacted_reviewers": "AccessReviewInstanceContactedReviewersOperations", - "access_review_default_settings": "AccessReviewDefaultSettingsOperations", - "access_review_schedule_definitions_assigned_for_my_approval": "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "access_review_instances_assigned_for_my_approval": "AccessReviewInstancesAssignedForMyApprovalOperations", - "access_review_instance_my_decisions": "AccessReviewInstanceMyDecisionsOperations", - "tenant_level_access_review_instance_contacted_reviewers": "TenantLevelAccessReviewInstanceContactedReviewersOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 58ec9e4d0fea..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewInstanceContactedReviewersOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_instance_contacted_reviewers: - AccessReviewInstanceContactedReviewersOperations operations - :vartype access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations - :ivar tenant_level_access_review_instance_contacted_reviewers: - TenantLevelAccessReviewInstanceContactedReviewersOperations operations - :vartype tenant_level_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - self.tenant_level_access_review_instance_contacted_reviewers = ( - TenantLevelAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" - ) - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py deleted file mode 100644 index 0972d8eedae4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-07-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index dda9abe5b586..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations -from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewInstanceContactedReviewersOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", - "TenantLevelAccessReviewInstanceContactedReviewersOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index 0a0b1e152442..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,155 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_decisions_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index 0690b78e1e5a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,381 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_my_decisions_operations import ( - build_get_by_id_request, - build_list_request, - build_patch_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace_async - async def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py deleted file mode 100644 index ef3aba0b7ede..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,367 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_operations import ( - build_accept_recommendations_request, - build_apply_decisions_request, - build_reset_decisions_request, - build_send_reminders_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace_async - async def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace_async - async def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace_async - async def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace_async - async def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index 84b325b2e4ec..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,218 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_assigned_for_my_approval_operations import ( - build_get_by_id_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py deleted file mode 100644 index 255209641f6c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,366 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instances_operations import ( - build_create_request, - build_get_by_id_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } - - @overload - async def create( - self, - schedule_definition_id: str, - id: str, - properties: _models.AccessReviewInstanceProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - schedule_definition_id: str, - id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - schedule_definition_id: str, - id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - - request = build_create_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index 3c1436545a90..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,466 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_operations import ( - build_create_or_update_by_id_request, - build_delete_by_id_request, - build_get_by_id_request, - build_list_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py deleted file mode 100644 index e8116873c26a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.aio.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py deleted file mode 100644 index 2d6f150deeda..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AccessReviewContactedReviewer -from ._models_py3 import AccessReviewContactedReviewerListResult -from ._models_py3 import AccessReviewDecision -from ._models_py3 import AccessReviewDecisionIdentity -from ._models_py3 import AccessReviewDecisionListResult -from ._models_py3 import AccessReviewDecisionProperties -from ._models_py3 import AccessReviewDecisionResource -from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity -from ._models_py3 import AccessReviewDecisionUserIdentity -from ._models_py3 import AccessReviewDefaultSettings -from ._models_py3 import AccessReviewInstance -from ._models_py3 import AccessReviewInstanceListResult -from ._models_py3 import AccessReviewInstanceProperties -from ._models_py3 import AccessReviewReviewer -from ._models_py3 import AccessReviewScheduleDefinition -from ._models_py3 import AccessReviewScheduleDefinitionListResult -from ._models_py3 import AccessReviewScheduleDefinitionProperties -from ._models_py3 import AccessReviewScheduleSettings -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorDefinitionProperties -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult - -from ._authorization_management_client_enums import AccessRecommendationType -from ._authorization_management_client_enums import AccessReviewActorIdentityType -from ._authorization_management_client_enums import AccessReviewApplyResult -from ._authorization_management_client_enums import AccessReviewInstanceReviewersType -from ._authorization_management_client_enums import AccessReviewInstanceStatus -from ._authorization_management_client_enums import AccessReviewRecurrencePatternType -from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType -from ._authorization_management_client_enums import AccessReviewResult -from ._authorization_management_client_enums import AccessReviewReviewerType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus -from ._authorization_management_client_enums import AccessReviewScopeAssignmentState -from ._authorization_management_client_enums import AccessReviewScopePrincipalType -from ._authorization_management_client_enums import DecisionResourceType -from ._authorization_management_client_enums import DecisionTargetType -from ._authorization_management_client_enums import DefaultDecisionType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessReviewContactedReviewer", - "AccessReviewContactedReviewerListResult", - "AccessReviewDecision", - "AccessReviewDecisionIdentity", - "AccessReviewDecisionListResult", - "AccessReviewDecisionProperties", - "AccessReviewDecisionResource", - "AccessReviewDecisionServicePrincipalIdentity", - "AccessReviewDecisionUserIdentity", - "AccessReviewDefaultSettings", - "AccessReviewInstance", - "AccessReviewInstanceListResult", - "AccessReviewInstanceProperties", - "AccessReviewReviewer", - "AccessReviewScheduleDefinition", - "AccessReviewScheduleDefinitionListResult", - "AccessReviewScheduleDefinitionProperties", - "AccessReviewScheduleSettings", - "ErrorDefinition", - "ErrorDefinitionProperties", - "Operation", - "OperationDisplay", - "OperationListResult", - "AccessRecommendationType", - "AccessReviewActorIdentityType", - "AccessReviewApplyResult", - "AccessReviewInstanceReviewersType", - "AccessReviewInstanceStatus", - "AccessReviewRecurrencePatternType", - "AccessReviewRecurrenceRangeType", - "AccessReviewResult", - "AccessReviewReviewerType", - "AccessReviewScheduleDefinitionReviewersType", - "AccessReviewScheduleDefinitionStatus", - "AccessReviewScopeAssignmentState", - "AccessReviewScopePrincipalType", - "DecisionResourceType", - "DecisionTargetType", - "DefaultDecisionType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index 978ae5ca2ba4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,162 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessRecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The feature- generated recommendation shown to the reviewer.""" - - APPROVE = "Approve" - DENY = "Deny" - NO_INFO_AVAILABLE = "NoInfoAvailable" - - -class AccessReviewActorIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewApplyResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The outcome of applying the decision.""" - - NEW = "New" - APPLYING = "Applying" - APPLIED_SUCCESSFULLY = "AppliedSuccessfully" - APPLIED_WITH_UNKNOWN_FAILURE = "AppliedWithUnknownFailure" - APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" - APPLY_NOT_SUPPORTED = "ApplyNotSupported" - - -class AccessReviewInstanceReviewersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - ASSIGNED = "Assigned" - SELF = "Self" - MANAGERS = "Managers" - - -class AccessReviewInstanceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an access review instance.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewRecurrencePatternType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence type : weekly, monthly, etc.""" - - WEEKLY = "weekly" - ABSOLUTE_MONTHLY = "absoluteMonthly" - - -class AccessReviewRecurrenceRangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recurrence range type. The possible values are: endDate, noEnd, numbered.""" - - END_DATE = "endDate" - NO_END = "noEnd" - NUMBERED = "numbered" - - -class AccessReviewResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The decision on the approval step. This value is initially set to NotReviewed. Approvers can - take action of Approve/Deny. - """ - - APPROVE = "Approve" - DENY = "Deny" - NOT_REVIEWED = "NotReviewed" - DONT_KNOW = "DontKnow" - NOT_NOTIFIED = "NotNotified" - - -class AccessReviewReviewerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type : user/servicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class AccessReviewScheduleDefinitionReviewersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """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. - """ - - ASSIGNED = "Assigned" - SELF = "Self" - MANAGERS = "Managers" - - -class AccessReviewScheduleDefinitionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This read-only field specifies the status of an accessReview.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - COMPLETED = "Completed" - APPLIED = "Applied" - INITIALIZING = "Initializing" - APPLYING = "Applying" - COMPLETING = "Completing" - SCHEDULED = "Scheduled" - AUTO_REVIEWING = "AutoReviewing" - AUTO_REVIEWED = "AutoReviewed" - STARTING = "Starting" - - -class AccessReviewScopeAssignmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The role assignment state eligible/active to review.""" - - ELIGIBLE = "eligible" - ACTIVE = "active" - - -class AccessReviewScopePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type user/servicePrincipal to review.""" - - USER = "user" - GUEST_USER = "guestUser" - SERVICE_PRINCIPAL = "servicePrincipal" - USER_GROUP = "user,group" - REDEEMED_GUEST_USER = "redeemedGuestUser" - - -class DecisionResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of resource.""" - - AZURE_ROLE = "azureRole" - - -class DecisionTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of decision target : User/ServicePrincipal.""" - - USER = "user" - SERVICE_PRINCIPAL = "servicePrincipal" - - -class DefaultDecisionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This specifies the behavior for the autoReview feature when an access review completes.""" - - APPROVE = "Approve" - DENY = "Deny" - RECOMMENDATION = "Recommendation" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py deleted file mode 100644 index 3d2415396bf5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2051 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AccessReviewContactedReviewer(_serialization.Model): - """Access Review Contacted Reviewer. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review reviewer id. - :vartype id: str - :ivar name: The access review reviewer id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar user_display_name: The display name of the reviewer. - :vartype user_display_name: str - :ivar user_principal_name: The user principal name of the reviewer. - :vartype user_principal_name: str - :ivar created_date_time: Date Time when the reviewer was contacted. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "user_display_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - "created_date_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, - "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, - "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.user_display_name = None - self.user_principal_name = None - self.created_date_time = None - - -class AccessReviewContactedReviewerListResult(_serialization.Model): - """List of access review contacted reviewers. - - :ivar value: Access Review Contacted Reviewer. - :vartype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Contacted Reviewer. - :paramtype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :ivar type_properties_resource_type: The type of resource. "azureRole" - :vartype type_properties_resource_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType - :ivar id_properties_resource_id: The id of resource associated with a decision record. - :vartype id_properties_resource_id: str - :ivar display_name_properties_resource_display_name: The display name of resource associated - with a decision record. - :vartype display_name_properties_resource_display_name: str - :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype type_properties_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType - :ivar id_properties_principal_id: The id of principal whose access was reviewed. - :vartype id_properties_principal_id: str - :ivar display_name_properties_principal_display_name: The display name of the user whose access - was reviewed. - :vartype display_name_properties_principal_display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_properties_applied_by_principal_id": {"readonly": True}, - "principal_type_properties_applied_by_principal_type": {"readonly": True}, - "principal_name_properties_applied_by_principal_name": {"readonly": True}, - "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, - "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, - "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, - "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, - "id_properties_resource_id": {"readonly": True}, - "display_name_properties_resource_display_name": {"readonly": True}, - "id_properties_principal_id": {"readonly": True}, - "display_name_properties_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "recommendation": {"key": "properties.recommendation", "type": "str"}, - "decision": {"key": "properties.decision", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "properties.applyResult", "type": "str"}, - "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, - "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, - "principal_type_properties_applied_by_principal_type": { - "key": "properties.appliedBy.principalType", - "type": "str", - }, - "principal_name_properties_applied_by_principal_name": { - "key": "properties.appliedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_applied_by_user_principal_name": { - "key": "properties.appliedBy.userPrincipalName", - "type": "str", - }, - "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, - "principal_type_properties_reviewed_by_principal_type": { - "key": "properties.reviewedBy.principalType", - "type": "str", - }, - "principal_name_properties_reviewed_by_principal_name": { - "key": "properties.reviewedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_reviewed_by_user_principal_name": { - "key": "properties.reviewedBy.userPrincipalName", - "type": "str", - }, - "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, - "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, - "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, - "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, - "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, - "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_resource_type: Optional[str] = None - self.id_properties_resource_id = None - self.display_name_properties_resource_display_name = None - self.type_properties_principal_type: Optional[str] = None - self.id_properties_principal_id = None - self.display_name_properties_principal_display_name = None - - -class AccessReviewDecisionIdentity(_serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - _subtype_map = { - "type": { - "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", - "user": "AccessReviewDecisionUserIdentity", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id = None - self.display_name = None - - -class AccessReviewDecisionListResult(_serialization.Model): - """List of access review decisions. - - :ivar value: Access Review Decision list. - :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewDecision]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewDecision"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Decision list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :ivar type_resource_type: The type of resource. "azureRole" - :vartype type_resource_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType - :ivar id_resource_id: The id of resource associated with a decision record. - :vartype id_resource_id: str - :ivar display_name_resource_display_name: The display name of resource associated with a - decision record. - :vartype display_name_resource_display_name: str - :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values - are: "user" and "servicePrincipal". - :vartype type_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType - :ivar id_principal_id: The id of principal whose access was reviewed. - :vartype id_principal_id: str - :ivar display_name_principal_display_name: The display name of the user whose access was - reviewed. - :vartype display_name_principal_display_name: str - """ - - _validation = { - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_applied_by_principal_id": {"readonly": True}, - "principal_type_applied_by_principal_type": {"readonly": True}, - "principal_name_applied_by_principal_name": {"readonly": True}, - "user_principal_name_applied_by_user_principal_name": {"readonly": True}, - "principal_id_reviewed_by_principal_id": {"readonly": True}, - "principal_type_reviewed_by_principal_type": {"readonly": True}, - "principal_name_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, - "id_resource_id": {"readonly": True}, - "display_name_resource_display_name": {"readonly": True}, - "id_principal_id": {"readonly": True}, - "display_name_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "recommendation": {"key": "recommendation", "type": "str"}, - "decision": {"key": "decision", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "applyResult", "type": "str"}, - "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, - "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, - "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, - "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, - "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, - "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, - "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, - "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, - "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, - "type_resource_type": {"key": "resource.type", "type": "str"}, - "id_resource_id": {"key": "resource.id", "type": "str"}, - "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, - "type_principal_type": {"key": "principal.type", "type": "str"}, - "id_principal_id": {"key": "principal.id", "type": "str"}, - "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type_resource_type: Optional[str] = None - self.id_resource_id = None - self.display_name_resource_display_name = None - self.type_principal_type: Optional[str] = None - self.id_principal_id = None - self.display_name_principal_display_name = None - - -class AccessReviewDecisionResource(_serialization.Model): - """Target of the decision. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of resource. Required. "azureRole" - :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType - :ivar id: The id of resource associated with a decision record. - :vartype id: str - :ivar display_name: The display name of resource associated with a decision record. - :vartype display_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id = None - self.display_name = None - - -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): - """Service Principal Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "app_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "app_id": {"key": "appId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "servicePrincipal" - self.app_id = None - - -class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): - """User Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "user_principal_name": {"key": "userPrincipalName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "user" - self.user_principal_name = None - - -class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "properties.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, - "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_recurrence_range_type = type_properties_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type - self.interval = interval - - -class AccessReviewInstance(_serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - - -class AccessReviewInstanceListResult(_serialization.Model): - """List of Access Review Instances. - - :ivar value: Access Review Instance list. - :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewInstanceProperties(_serialization.Model): - """Access Review Instance properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - """ - super().__init__(**kwargs) - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - - -class AccessReviewReviewer(_serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The id of the reviewer(user/servicePrincipal). - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - "principal_type": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: The id of the reviewer(user/servicePrincipal). - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.principal_type = None - - -class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and - "redeemedGuestUser". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. - :vartype expand_nested_memberships: bool - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_properties_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_properties_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, - "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, - "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, - "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, - "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": { - "key": "properties.settings.justificationRequiredOnApproval", - "type": "bool", - }, - "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": { - "key": "properties.settings.recommendationLookBackDuration", - "type": "duration", - }, - "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, - "type_properties_settings_recurrence_range_type": { - "key": "properties.settings.recurrence.range.type", - "type": "str", - }, - "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_settings_recurrence_pattern_type": { - "key": "properties.settings.recurrence.pattern.type", - "type": "str", - }, - "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, - "principal_type_properties_created_by_principal_type": { - "key": "properties.createdBy.principalType", - "type": "str", - }, - "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - expand_nested_memberships: Optional[bool] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_settings_recurrence_range_type: Optional[ - Union[str, "_models.AccessReviewRecurrenceRangeType"] - ] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_settings_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or - not. - :paramtype expand_nested_memberships: bool - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The - possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and - "numbered". - :paramtype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, - monthly, etc. Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.expand_nested_memberships = expand_nested_memberships - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(_serialization.Model): - """List of Access Review Schedule Definitions. - - :ivar value: Access Review Schedule Definition list. - :vartype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Schedule Definition list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Known values are: "user", "guestUser", "servicePrincipal", "user,group", and - "redeemedGuestUser". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. - :vartype expand_nested_memberships: bool - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known - values are: "weekly" and "absoluteMonthly". - :vartype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, - "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, - "assignment_state": {"key": "scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, - "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, - "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, - "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "createdBy.principalId", "type": "str"}, - "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, - "principal_name": {"key": "createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - expand_nested_memberships: Optional[bool] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or - not. - :paramtype expand_nested_memberships: bool - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.expand_nested_memberships = expand_nested_memberships - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_settings_recurrence_range_type = type_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Settings of an Access Review. - - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :vartype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _attribute_map = { - "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, - "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, - "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, - "interval": {"key": "recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :paramtype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_recurrence_range_type = type_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_recurrence_pattern_type = type_recurrence_pattern_type - self.interval = interval - - -class ErrorDefinition(_serialization.Model): - """Error description and code explaining why an operation failed. - - :ivar error: Error of the list gateway status. - :vartype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionProperties"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error of the list gateway status. - :paramtype error: - ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorDefinitionProperties(_serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :ivar code: Error code of list gateway. - :vartype code: str - """ - - _validation = { - "message": {"readonly": True}, - } - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code of list gateway. - :paramtype code: str - """ - super().__init__(**kwargs) - self.message = None - self.code = code - - -class Operation(_serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :ivar name: Name of the operation. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay - :ivar origin: Origin of the operation. - :vartype origin: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation. - :paramtype name: str - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay - :keyword origin: Origin of the operation. - :paramtype origin: str - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - - -class OperationDisplay(_serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection value. - :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] - :keyword next_link: The URI that can be used to request the next set of paged results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py deleted file mode 100644 index dda9abe5b586..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations -from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewInstanceContactedReviewersOperations", - "AccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", - "TenantLevelAccessReviewInstanceContactedReviewersOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py deleted file mode 100644 index f8b6d3a3d816..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_put_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py deleted file mode 100644 index 19b8ad38430f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py +++ /dev/null @@ -1,181 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceContactedReviewersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_contacted_reviewers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewContactedReviewer"]: - """Get access review instance contacted reviewers. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewContactedReviewer or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py deleted file mode 100644 index f6c1fc47e437..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: - """Get access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index f1f5b55e4b6f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,472 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request(schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "decisionId": _SERIALIZER.url("decision_id", decision_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace - def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py deleted file mode 100644 index ca56aff5c029..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,514 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_stop_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_reset_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_apply_decisions_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_send_reminders_request( - schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_accept_recommendations_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace - def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace - def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace - def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace - def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py deleted file mode 100644 index b33a2aa2103a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get single access review instance assigned for my approval. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py deleted file mode 100644 index d92292975e9f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py +++ /dev/null @@ -1,457 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request( - schedule_definition_id: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request(schedule_definition_id: str, id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewInstancesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_instances` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AccessReviewInstance"]: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstance or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstanceListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, id: str, **kwargs: Any) -> _models.AccessReviewInstance: - """Get access review instances. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } - - @overload - def create( - self, - schedule_definition_id: str, - id: str, - properties: _models.AccessReviewInstanceProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - schedule_definition_id: str, - id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - schedule_definition_id: str, - id: str, - properties: Union[_models.AccessReviewInstanceProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewInstance: - """Update access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param properties: Access review instance properties. Is either a - AccessReviewInstanceProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewInstance or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewInstanceProperties") - - request = build_create_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewInstance", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index 30a816283b29..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,168 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(*, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index da73e4b91a1a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,606 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_by_id_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_by_id_request( - schedule_definition_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request(schedule_definition_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace - def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace - def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py deleted file mode 100644 index 255bf222b33f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py deleted file mode 100644 index 38730f35e65f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ /dev/null @@ -1,179 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), - "id": _SERIALIZER.url("id", id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class TenantLevelAccessReviewInstanceContactedReviewersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_07_01_preview.AuthorizationManagementClient`'s - :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> Iterable["_models.AccessReviewContactedReviewer"]: - """Get access review instance contacted reviewers. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewContactedReviewer or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") - ) - cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py deleted file mode 100644 index 13a9f000d386..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,280 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewHistoryDefinitionInstanceOperations, - AccessReviewHistoryDefinitionInstancesOperations, - AccessReviewHistoryDefinitionOperations, - AccessReviewHistoryDefinitionsOperations, - AccessReviewInstanceContactedReviewersOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, - ScopeAccessReviewDefaultSettingsOperations, - ScopeAccessReviewHistoryDefinitionInstanceOperations, - ScopeAccessReviewHistoryDefinitionInstancesOperations, - ScopeAccessReviewHistoryDefinitionOperations, - ScopeAccessReviewHistoryDefinitionsOperations, - ScopeAccessReviewInstanceContactedReviewersOperations, - ScopeAccessReviewInstanceDecisionsOperations, - ScopeAccessReviewInstanceOperations, - ScopeAccessReviewInstancesOperations, - ScopeAccessReviewScheduleDefinitionsOperations, - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.operations.Operations - :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations - :vartype access_review_history_definitions: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionsOperations - :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations - :vartype access_review_history_definition: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionOperations - :ivar access_review_history_definition_instance: - AccessReviewHistoryDefinitionInstanceOperations operations - :vartype access_review_history_definition_instance: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstanceOperations - :ivar access_review_history_definition_instances: - AccessReviewHistoryDefinitionInstancesOperations operations - :vartype access_review_history_definition_instances: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstancesOperations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_instance_contacted_reviewers: - AccessReviewInstanceContactedReviewersOperations operations - :vartype access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceContactedReviewersOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations - operations - :vartype scope_access_review_history_definitions: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionsOperations - :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations - operations - :vartype scope_access_review_history_definition: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionOperations - :ivar scope_access_review_history_definition_instance: - ScopeAccessReviewHistoryDefinitionInstanceOperations operations - :vartype scope_access_review_history_definition_instance: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations - :ivar scope_access_review_history_definition_instances: - ScopeAccessReviewHistoryDefinitionInstancesOperations operations - :vartype scope_access_review_history_definition_instances: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations - :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations - operations - :vartype scope_access_review_schedule_definitions: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewScheduleDefinitionsOperations - :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations - :vartype scope_access_review_instances: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstancesOperations - :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations - :vartype scope_access_review_instance: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceOperations - :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations - operations - :vartype scope_access_review_instance_decisions: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceDecisionsOperations - :ivar scope_access_review_instance_contacted_reviewers: - ScopeAccessReviewInstanceContactedReviewersOperations operations - :vartype scope_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceContactedReviewersOperations - :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations - operations - :vartype scope_access_review_default_settings: - azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceMyDecisionsOperations - :ivar tenant_level_access_review_instance_contacted_reviewers: - TenantLevelAccessReviewInstanceContactedReviewersOperations operations - :vartype tenant_level_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.tenant_level_access_review_instance_contacted_reviewers = ( - TenantLevelAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py deleted file mode 100644 index 3e20a7c4c988..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json deleted file mode 100644 index 2e1c41594826..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_metadata.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "chosen_version": "2021-12-01-preview", - "total_api_version_list": ["2021-12-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "access_review_history_definitions": "AccessReviewHistoryDefinitionsOperations", - "access_review_history_definition": "AccessReviewHistoryDefinitionOperations", - "access_review_history_definition_instance": "AccessReviewHistoryDefinitionInstanceOperations", - "access_review_history_definition_instances": "AccessReviewHistoryDefinitionInstancesOperations", - "access_review_schedule_definitions": "AccessReviewScheduleDefinitionsOperations", - "access_review_instances": "AccessReviewInstancesOperations", - "access_review_instance": "AccessReviewInstanceOperations", - "access_review_instance_decisions": "AccessReviewInstanceDecisionsOperations", - "access_review_instance_contacted_reviewers": "AccessReviewInstanceContactedReviewersOperations", - "access_review_default_settings": "AccessReviewDefaultSettingsOperations", - "scope_access_review_history_definitions": "ScopeAccessReviewHistoryDefinitionsOperations", - "scope_access_review_history_definition": "ScopeAccessReviewHistoryDefinitionOperations", - "scope_access_review_history_definition_instance": "ScopeAccessReviewHistoryDefinitionInstanceOperations", - "scope_access_review_history_definition_instances": "ScopeAccessReviewHistoryDefinitionInstancesOperations", - "scope_access_review_schedule_definitions": "ScopeAccessReviewScheduleDefinitionsOperations", - "scope_access_review_instances": "ScopeAccessReviewInstancesOperations", - "scope_access_review_instance": "ScopeAccessReviewInstanceOperations", - "scope_access_review_instance_decisions": "ScopeAccessReviewInstanceDecisionsOperations", - "scope_access_review_instance_contacted_reviewers": "ScopeAccessReviewInstanceContactedReviewersOperations", - "scope_access_review_default_settings": "ScopeAccessReviewDefaultSettingsOperations", - "access_review_schedule_definitions_assigned_for_my_approval": "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "access_review_instances_assigned_for_my_approval": "AccessReviewInstancesAssignedForMyApprovalOperations", - "access_review_instance_my_decisions": "AccessReviewInstanceMyDecisionsOperations", - "tenant_level_access_review_instance_contacted_reviewers": "TenantLevelAccessReviewInstanceContactedReviewersOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index aa83068b7f1d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,280 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AccessReviewDefaultSettingsOperations, - AccessReviewHistoryDefinitionInstanceOperations, - AccessReviewHistoryDefinitionInstancesOperations, - AccessReviewHistoryDefinitionOperations, - AccessReviewHistoryDefinitionsOperations, - AccessReviewInstanceContactedReviewersOperations, - AccessReviewInstanceDecisionsOperations, - AccessReviewInstanceMyDecisionsOperations, - AccessReviewInstanceOperations, - AccessReviewInstancesAssignedForMyApprovalOperations, - AccessReviewInstancesOperations, - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, - AccessReviewScheduleDefinitionsOperations, - Operations, - ScopeAccessReviewDefaultSettingsOperations, - ScopeAccessReviewHistoryDefinitionInstanceOperations, - ScopeAccessReviewHistoryDefinitionInstancesOperations, - ScopeAccessReviewHistoryDefinitionOperations, - ScopeAccessReviewHistoryDefinitionsOperations, - ScopeAccessReviewInstanceContactedReviewersOperations, - ScopeAccessReviewInstanceDecisionsOperations, - ScopeAccessReviewInstanceOperations, - ScopeAccessReviewInstancesOperations, - ScopeAccessReviewScheduleDefinitionsOperations, - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Access reviews service provides the workflow for running access reviews on different kind of - resources. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.Operations - :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations - :vartype access_review_history_definitions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionsOperations - :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations - :vartype access_review_history_definition: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionOperations - :ivar access_review_history_definition_instance: - AccessReviewHistoryDefinitionInstanceOperations operations - :vartype access_review_history_definition_instance: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstanceOperations - :ivar access_review_history_definition_instances: - AccessReviewHistoryDefinitionInstancesOperations operations - :vartype access_review_history_definition_instances: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstancesOperations - :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations - :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesOperations - :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceOperations - :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations - :ivar access_review_instance_contacted_reviewers: - AccessReviewInstanceContactedReviewersOperations operations - :vartype access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations - :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations - operations - :vartype scope_access_review_history_definitions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations - :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations - operations - :vartype scope_access_review_history_definition: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionOperations - :ivar scope_access_review_history_definition_instance: - ScopeAccessReviewHistoryDefinitionInstanceOperations operations - :vartype scope_access_review_history_definition_instance: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations - :ivar scope_access_review_history_definition_instances: - ScopeAccessReviewHistoryDefinitionInstancesOperations operations - :vartype scope_access_review_history_definition_instances: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations - :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations - operations - :vartype scope_access_review_schedule_definitions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations - :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations - :vartype scope_access_review_instances: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstancesOperations - :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations - :vartype scope_access_review_instance: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceOperations - :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations - operations - :vartype scope_access_review_instance_decisions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceDecisionsOperations - :ivar scope_access_review_instance_contacted_reviewers: - ScopeAccessReviewInstanceContactedReviewersOperations operations - :vartype scope_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations - :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations - operations - :vartype scope_access_review_default_settings: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: - AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations - :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations - :ivar tenant_level_access_review_instance_contacted_reviewers: - TenantLevelAccessReviewInstanceContactedReviewersOperations operations - :vartype tenant_level_access_review_instance_contacted_reviewers: - azure.mgmt.authorization.v2021_12_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_schedule_definitions_assigned_for_my_approval = ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - ) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.tenant_level_access_review_instance_contacted_reviewers = ( - TenantLevelAccessReviewInstanceContactedReviewersOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py deleted file mode 100644 index 7c6c3db83976..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2021-12-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/__init__.py deleted file mode 100644 index d04d147885dc..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations -from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations -from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations -from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations -from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations -from ._scope_access_review_history_definition_instance_operations import ( - ScopeAccessReviewHistoryDefinitionInstanceOperations, -) -from ._scope_access_review_history_definition_instances_operations import ( - ScopeAccessReviewHistoryDefinitionInstancesOperations, -) -from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations -from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations -from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations -from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations -from ._scope_access_review_instance_contacted_reviewers_operations import ( - ScopeAccessReviewInstanceContactedReviewersOperations, -) -from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations -from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewHistoryDefinitionsOperations", - "AccessReviewHistoryDefinitionOperations", - "AccessReviewHistoryDefinitionInstanceOperations", - "AccessReviewHistoryDefinitionInstancesOperations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewInstanceContactedReviewersOperations", - "AccessReviewDefaultSettingsOperations", - "ScopeAccessReviewHistoryDefinitionsOperations", - "ScopeAccessReviewHistoryDefinitionOperations", - "ScopeAccessReviewHistoryDefinitionInstanceOperations", - "ScopeAccessReviewHistoryDefinitionInstancesOperations", - "ScopeAccessReviewScheduleDefinitionsOperations", - "ScopeAccessReviewInstancesOperations", - "ScopeAccessReviewInstanceOperations", - "ScopeAccessReviewInstanceDecisionsOperations", - "ScopeAccessReviewInstanceContactedReviewersOperations", - "ScopeAccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", - "TenantLevelAccessReviewInstanceContactedReviewersOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py deleted file mode 100644 index 52327653b7f3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_default_settings_operations.py +++ /dev/null @@ -1,225 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_default_settings_operations import build_get_request, build_put_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewDefaultSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_default_settings` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - request = build_get_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } - - @overload - async def put( - self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def put( - self, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def put( - self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any - ) -> _models.AccessReviewDefaultSettings: - """Get access review default settings for the subscription. - - :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings - type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDefaultSettings or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleSettings") - - request = build_put_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.put.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - put.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py deleted file mode 100644 index 90c547171108..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py +++ /dev/null @@ -1,149 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceContactedReviewersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_contacted_reviewers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: - """Get access review instance contacted reviewers. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewContactedReviewer or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py deleted file mode 100644 index 05e1a248f909..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ /dev/null @@ -1,381 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_my_decisions_operations import ( - build_get_by_id_request, - build_list_request, - build_patch_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceMyDecisionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance_my_decisions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewDecision"]: - """Get my access review instance decisions. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecision or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" - } - - @distributed_trace_async - async def get_by_id( - self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any - ) -> _models.AccessReviewDecision: - """Get my single access review instance decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: _models.AccessReviewDecisionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def patch( - self, - schedule_definition_id: str, - id: str, - decision_id: str, - properties: Union[_models.AccessReviewDecisionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewDecision: - """Record a decision. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :param decision_id: The id of the decision record. Required. - :type decision_id: str - :param properties: Access review decision properties to patch. Is either a - AccessReviewDecisionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewDecision or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewDecisionProperties") - - request = build_patch_request( - schedule_definition_id=schedule_definition_id, - id=id, - decision_id=decision_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewDecision", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - patch.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py deleted file mode 100644 index bf8e8e0ab3d8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_instance_operations.py +++ /dev/null @@ -1,367 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_instance_operations import ( - build_accept_recommendations_request, - build_apply_decisions_request, - build_reset_decisions_request, - build_send_reminders_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewInstanceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_instance` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to stop an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" - } - - @distributed_trace_async - async def reset_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to reset all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_reset_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.reset_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - reset_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" - } - - @distributed_trace_async - async def apply_decisions( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to apply all decisions for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_apply_decisions_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.apply_decisions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - apply_decisions.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" - } - - @distributed_trace_async - async def send_reminders( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to send reminders for an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_send_reminders_request( - schedule_definition_id=schedule_definition_id, - id=id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.send_reminders.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - send_reminders.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" - } - - @distributed_trace_async - async def accept_recommendations( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> None: - """An action to accept recommendations for decision in an access review instance. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_accept_recommendations_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.accept_recommendations.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - accept_recommendations.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py deleted file mode 100644 index 784c30e2d082..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ /dev/null @@ -1,146 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review instances assigned for my approval. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py deleted file mode 100644 index e2b57209e862..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ /dev/null @@ -1,466 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._access_review_schedule_definitions_operations import ( - build_create_or_update_by_id_request, - build_delete_by_id_request, - build_get_by_id_request, - build_list_request, - build_stop_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AccessReviewScheduleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`access_review_schedule_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: - """Get access review schedule definitions. - - :param filter: The filter to apply on the operation. Other than standard filters, one custom - filter option is supported : 'assignedToMeToReview()'. When one specified - $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" - } - - @distributed_trace_async - async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: - """Get single access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def delete_by_id( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Delete access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @overload - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: _models.AccessReviewScheduleDefinitionProperties, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_by_id( - self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Required. - :type properties: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_by_id( - self, - schedule_definition_id: str, - properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], - **kwargs: Any - ) -> _models.AccessReviewScheduleDefinition: - """Create or Update access review schedule definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param properties: Access review schedule definition properties. Is either a - AccessReviewScheduleDefinitionProperties type or a IO type. Required. - :type properties: - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessReviewScheduleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties - else: - _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") - - request = build_create_or_update_by_id_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update_by_id.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" - } - - @distributed_trace_async - async def stop( # pylint: disable=inconsistent-return-statements - self, schedule_definition_id: str, **kwargs: Any - ) -> None: - """Stop access review definition. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_stop_request( - schedule_definition_id=schedule_definition_id, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.stop.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - stop.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py deleted file mode 100644 index 393af574b8e3..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class Operations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`operations` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists the operations available from this provider. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/operations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py deleted file mode 100644 index 9d63f1c79913..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantLevelAccessReviewInstanceContactedReviewersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s - :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, schedule_definition_id: str, id: str, **kwargs: Any - ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: - """Get access review instance contacted reviewers. - - :param schedule_definition_id: The id of the access review schedule definition. Required. - :type schedule_definition_id: str - :param id: The id of the access review instance. Required. - :type id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewContactedReviewer or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - schedule_definition_id=schedule_definition_id, - id=id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/__init__.py deleted file mode 100644 index 4caea33af975..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/__init__.py +++ /dev/null @@ -1,121 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import AccessReviewContactedReviewer -from ._models_py3 import AccessReviewContactedReviewerListResult -from ._models_py3 import AccessReviewDecision -from ._models_py3 import AccessReviewDecisionIdentity -from ._models_py3 import AccessReviewDecisionInsight -from ._models_py3 import AccessReviewDecisionInsightProperties -from ._models_py3 import AccessReviewDecisionListResult -from ._models_py3 import AccessReviewDecisionProperties -from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity -from ._models_py3 import AccessReviewDecisionUserIdentity -from ._models_py3 import AccessReviewDecisionUserSignInInsightProperties -from ._models_py3 import AccessReviewDefaultSettings -from ._models_py3 import AccessReviewHistoryDefinition -from ._models_py3 import AccessReviewHistoryDefinitionInstanceListResult -from ._models_py3 import AccessReviewHistoryDefinitionListResult -from ._models_py3 import AccessReviewHistoryDefinitionProperties -from ._models_py3 import AccessReviewHistoryInstance -from ._models_py3 import AccessReviewInstance -from ._models_py3 import AccessReviewInstanceListResult -from ._models_py3 import AccessReviewInstanceProperties -from ._models_py3 import AccessReviewReviewer -from ._models_py3 import AccessReviewScheduleDefinition -from ._models_py3 import AccessReviewScheduleDefinitionListResult -from ._models_py3 import AccessReviewScheduleDefinitionProperties -from ._models_py3 import AccessReviewScheduleSettings -from ._models_py3 import AccessReviewScope -from ._models_py3 import ErrorDefinition -from ._models_py3 import ErrorDefinitionProperties -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import RecordAllDecisionsProperties - -from ._authorization_management_client_enums import AccessRecommendationType -from ._authorization_management_client_enums import AccessReviewActorIdentityType -from ._authorization_management_client_enums import AccessReviewApplyResult -from ._authorization_management_client_enums import AccessReviewDecisionInsightType -from ._authorization_management_client_enums import AccessReviewDecisionPrincipalResourceMembershipType -from ._authorization_management_client_enums import AccessReviewHistoryDefinitionStatus -from ._authorization_management_client_enums import AccessReviewInstanceReviewersType -from ._authorization_management_client_enums import AccessReviewInstanceStatus -from ._authorization_management_client_enums import AccessReviewRecurrencePatternType -from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType -from ._authorization_management_client_enums import AccessReviewResult -from ._authorization_management_client_enums import AccessReviewReviewerType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType -from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus -from ._authorization_management_client_enums import AccessReviewScopeAssignmentState -from ._authorization_management_client_enums import AccessReviewScopePrincipalType -from ._authorization_management_client_enums import DecisionResourceType -from ._authorization_management_client_enums import DecisionTargetType -from ._authorization_management_client_enums import DefaultDecisionType -from ._authorization_management_client_enums import RecordAllDecisionsResult -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AccessReviewContactedReviewer", - "AccessReviewContactedReviewerListResult", - "AccessReviewDecision", - "AccessReviewDecisionIdentity", - "AccessReviewDecisionInsight", - "AccessReviewDecisionInsightProperties", - "AccessReviewDecisionListResult", - "AccessReviewDecisionProperties", - "AccessReviewDecisionServicePrincipalIdentity", - "AccessReviewDecisionUserIdentity", - "AccessReviewDecisionUserSignInInsightProperties", - "AccessReviewDefaultSettings", - "AccessReviewHistoryDefinition", - "AccessReviewHistoryDefinitionInstanceListResult", - "AccessReviewHistoryDefinitionListResult", - "AccessReviewHistoryDefinitionProperties", - "AccessReviewHistoryInstance", - "AccessReviewInstance", - "AccessReviewInstanceListResult", - "AccessReviewInstanceProperties", - "AccessReviewReviewer", - "AccessReviewScheduleDefinition", - "AccessReviewScheduleDefinitionListResult", - "AccessReviewScheduleDefinitionProperties", - "AccessReviewScheduleSettings", - "AccessReviewScope", - "ErrorDefinition", - "ErrorDefinitionProperties", - "Operation", - "OperationDisplay", - "OperationListResult", - "RecordAllDecisionsProperties", - "AccessRecommendationType", - "AccessReviewActorIdentityType", - "AccessReviewApplyResult", - "AccessReviewDecisionInsightType", - "AccessReviewDecisionPrincipalResourceMembershipType", - "AccessReviewHistoryDefinitionStatus", - "AccessReviewInstanceReviewersType", - "AccessReviewInstanceStatus", - "AccessReviewRecurrencePatternType", - "AccessReviewRecurrenceRangeType", - "AccessReviewResult", - "AccessReviewReviewerType", - "AccessReviewScheduleDefinitionReviewersType", - "AccessReviewScheduleDefinitionStatus", - "AccessReviewScopeAssignmentState", - "AccessReviewScopePrincipalType", - "DecisionResourceType", - "DecisionTargetType", - "DefaultDecisionType", - "RecordAllDecisionsResult", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py deleted file mode 100644 index edfeb65e9e61..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2930 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class AccessReviewContactedReviewer(_serialization.Model): - """Access Review Contacted Reviewer. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review reviewer id. - :vartype id: str - :ivar name: The access review reviewer id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar user_display_name: The display name of the reviewer. - :vartype user_display_name: str - :ivar user_principal_name: The user principal name of the reviewer. - :vartype user_principal_name: str - :ivar created_date_time: Date Time when the reviewer was contacted. - :vartype created_date_time: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "user_display_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - "created_date_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, - "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, - "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.user_display_name = None - self.user_principal_name = None - self.created_date_time = None - - -class AccessReviewContactedReviewerListResult(_serialization.Model): - """List of access review contacted reviewers. - - :ivar value: Access Review Contacted Reviewer. - :vartype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Contacted Reviewer. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar insights: This is the collection of insights for this decision item. - :vartype insights: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] - :ivar membership_types: Every decision item in an access review represents a principal's - membership to a resource. This property represents details of the membership. Examples of this - detail might be whether the principal has direct access or indirect access. - :vartype membership_types: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :ivar type_properties_resource_type: The type of resource. "azureRole" - :vartype type_properties_resource_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType - :ivar id_properties_resource_id: The id of resource associated with a decision record. - :vartype id_properties_resource_id: str - :ivar display_name_properties_resource_display_name: The display name of resource associated - with a decision record. - :vartype display_name_properties_resource_display_name: str - :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype type_properties_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType - :ivar id_properties_principal_id: The id of principal whose access was reviewed. - :vartype id_properties_principal_id: str - :ivar display_name_properties_principal_display_name: The display name of the user whose access - was reviewed. - :vartype display_name_properties_principal_display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_properties_applied_by_principal_id": {"readonly": True}, - "principal_type_properties_applied_by_principal_type": {"readonly": True}, - "principal_name_properties_applied_by_principal_name": {"readonly": True}, - "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, - "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, - "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, - "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, - "id_properties_resource_id": {"readonly": True}, - "display_name_properties_resource_display_name": {"readonly": True}, - "id_properties_principal_id": {"readonly": True}, - "display_name_properties_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "recommendation": {"key": "properties.recommendation", "type": "str"}, - "decision": {"key": "properties.decision", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "properties.applyResult", "type": "str"}, - "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, - "insights": {"key": "properties.insights", "type": "[AccessReviewDecisionInsight]"}, - "membership_types": {"key": "properties.principalResourceMembership.membershipTypes", "type": "[str]"}, - "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, - "principal_type_properties_applied_by_principal_type": { - "key": "properties.appliedBy.principalType", - "type": "str", - }, - "principal_name_properties_applied_by_principal_name": { - "key": "properties.appliedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_applied_by_user_principal_name": { - "key": "properties.appliedBy.userPrincipalName", - "type": "str", - }, - "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, - "principal_type_properties_reviewed_by_principal_type": { - "key": "properties.reviewedBy.principalType", - "type": "str", - }, - "principal_name_properties_reviewed_by_principal_name": { - "key": "properties.reviewedBy.principalName", - "type": "str", - }, - "user_principal_name_properties_reviewed_by_user_principal_name": { - "key": "properties.reviewedBy.userPrincipalName", - "type": "str", - }, - "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, - "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, - "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, - "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, - "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, - "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, - membership_types: Optional[ - List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] - ] = None, - type_properties_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - :keyword insights: This is the collection of insights for this decision item. - :paramtype insights: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] - :keyword membership_types: Every decision item in an access review represents a principal's - membership to a resource. This property represents details of the membership. Examples of this - detail might be whether the principal has direct access or indirect access. - :paramtype membership_types: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] - :keyword type_properties_resource_type: The type of resource. "azureRole" - :paramtype type_properties_resource_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.insights = insights - self.membership_types = membership_types - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_resource_type = type_properties_resource_type - self.id_properties_resource_id = None - self.display_name_properties_resource_display_name = None - self.type_properties_principal_type: Optional[str] = None - self.id_properties_principal_id = None - self.display_name_properties_principal_display_name = None - - -class AccessReviewDecisionIdentity(_serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - _subtype_map = { - "type": { - "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", - "user": "AccessReviewDecisionUserIdentity", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.id = None - self.display_name = None - - -class AccessReviewDecisionInsight(_serialization.Model): - """Access Review Decision Insight. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review insight id. - :vartype id: str - :ivar name: The access review insight name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar type_properties_type: The type of insight. "userSignInInsight" - :vartype type_properties_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType - :ivar insight_created_date_time: Date Time when the insight was created. - :vartype insight_created_date_time: any - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "insight_created_date_time": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "insight_created_date_time": {"key": "properties.insightCreatedDateTime", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.type_properties_type: Optional[str] = None - self.insight_created_date_time = None - - -class AccessReviewDecisionInsightProperties(_serialization.Model): - """Details of the Insight. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AccessReviewDecisionUserSignInInsightProperties - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of insight. Required. "userSignInInsight" - :vartype type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType - :ivar insight_created_date_time: Date Time when the insight was created. - :vartype insight_created_date_time: any - """ - - _validation = { - "type": {"required": True}, - "insight_created_date_time": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, - } - - _subtype_map = {"type": {"userSignInInsight": "AccessReviewDecisionUserSignInInsightProperties"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.insight_created_date_time = None - - -class AccessReviewDecisionListResult(_serialization.Model): - """List of access review decisions. - - :ivar value: Access Review Decision list. - :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewDecision]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewDecision"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Decision list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values - are: "Approve", "Deny", and "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType - :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", - "DontKnow", and "NotNotified". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", - "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and - "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar insights: This is the collection of insights for this decision item. - :vartype insights: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] - :ivar membership_types: Every decision item in an access review represents a principal's - membership to a resource. This property represents details of the membership. Examples of this - detail might be whether the principal has direct access or indirect access. - :vartype membership_types: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :ivar type_resource_type: The type of resource. "azureRole" - :vartype type_resource_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType - :ivar id_resource_id: The id of resource associated with a decision record. - :vartype id_resource_id: str - :ivar display_name_resource_display_name: The display name of resource associated with a - decision record. - :vartype display_name_resource_display_name: str - :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values - are: "user" and "servicePrincipal". - :vartype type_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType - :ivar id_principal_id: The id of principal whose access was reviewed. - :vartype id_principal_id: str - :ivar display_name_principal_display_name: The display name of the user whose access was - reviewed. - :vartype display_name_principal_display_name: str - """ - - _validation = { - "recommendation": {"readonly": True}, - "reviewed_date_time": {"readonly": True}, - "apply_result": {"readonly": True}, - "applied_date_time": {"readonly": True}, - "principal_id_applied_by_principal_id": {"readonly": True}, - "principal_type_applied_by_principal_type": {"readonly": True}, - "principal_name_applied_by_principal_name": {"readonly": True}, - "user_principal_name_applied_by_user_principal_name": {"readonly": True}, - "principal_id_reviewed_by_principal_id": {"readonly": True}, - "principal_type_reviewed_by_principal_type": {"readonly": True}, - "principal_name_reviewed_by_principal_name": {"readonly": True}, - "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, - "id_resource_id": {"readonly": True}, - "display_name_resource_display_name": {"readonly": True}, - "id_principal_id": {"readonly": True}, - "display_name_principal_display_name": {"readonly": True}, - } - - _attribute_map = { - "recommendation": {"key": "recommendation", "type": "str"}, - "decision": {"key": "decision", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, - "apply_result": {"key": "applyResult", "type": "str"}, - "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, - "insights": {"key": "insights", "type": "[AccessReviewDecisionInsight]"}, - "membership_types": {"key": "principalResourceMembership.membershipTypes", "type": "[str]"}, - "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, - "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, - "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, - "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, - "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, - "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, - "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, - "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, - "type_resource_type": {"key": "resource.type", "type": "str"}, - "id_resource_id": {"key": "resource.id", "type": "str"}, - "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, - "type_principal_type": {"key": "principal.type", "type": "str"}, - "id_principal_id": {"key": "principal.id", "type": "str"}, - "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, - justification: Optional[str] = None, - insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, - membership_types: Optional[ - List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] - ] = None, - type_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision on the approval step. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", - "NotReviewed", "DontKnow", and "NotNotified". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - :keyword insights: This is the collection of insights for this decision item. - :paramtype insights: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] - :keyword membership_types: Every decision item in an access review represents a principal's - membership to a resource. This property represents details of the membership. Examples of this - detail might be whether the principal has direct access or indirect access. - :paramtype membership_types: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] - :keyword type_resource_type: The type of resource. "azureRole" - :paramtype type_resource_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType - """ - super().__init__(**kwargs) - self.recommendation = None - self.decision = decision - self.justification = justification - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.insights = insights - self.membership_types = membership_types - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type_resource_type = type_resource_type - self.id_resource_id = None - self.display_name_resource_display_name = None - self.type_principal_type: Optional[str] = None - self.id_principal_id = None - self.display_name_principal_display_name = None - - -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): - """Service Principal Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "app_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "app_id": {"key": "appId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "servicePrincipal" - self.app_id = None - - -class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): - """User Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: - "user" and "servicePrincipal". - :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - "type": {"required": True}, - "id": {"readonly": True}, - "display_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "user_principal_name": {"key": "userPrincipalName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "user" - self.user_principal_name = None - - -class AccessReviewDecisionUserSignInInsightProperties(AccessReviewDecisionInsightProperties): - """User Decision Target. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar type: The type of insight. Required. "userSignInInsight" - :vartype type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType - :ivar insight_created_date_time: Date Time when the insight was created. - :vartype insight_created_date_time: any - :ivar last_sign_in_date_time: Date Time when the user signed into the tenant. - :vartype last_sign_in_date_time: any - """ - - _validation = { - "type": {"required": True}, - "insight_created_date_time": {"readonly": True}, - "last_sign_in_date_time": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, - "last_sign_in_date_time": {"key": "lastSignInDateTime", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "userSignInInsight" - self.last_sign_in_date_time = None - - -class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "properties.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, - "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_recurrence_range_type = type_properties_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type - self.interval = interval - - -class AccessReviewHistoryDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review History Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review history definition id. - :vartype id: str - :ivar name: The access review history definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the history definition. - :vartype display_name: str - :ivar review_history_period_start_date_time: Date time used when selecting review data, all - reviews included in data start on or after this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_start_date_time: ~datetime.datetime - :ivar review_history_period_end_date_time: Date time used when selecting review data, all - reviews included in data end on or before this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_end_date_time: ~datetime.datetime - :ivar decisions: Collection of review decisions which the history data should be filtered on. - For example if Approve and Deny are supplied the data will only contain review results in which - the decision maker approved or denied a review request. - :vartype decisions: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] - :ivar status: This read-only field specifies the of the requested review history data. This is - either requested, in-progress, done or error. Known values are: "Requested", "InProgress", - "Done", and "Error". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus - :ivar created_date_time: Date time when history definition was created. - :vartype created_date_time: ~datetime.datetime - :ivar scopes: A collection of scopes used when selecting review history data. - :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] - :ivar instances: Set of access review history instances for this history definition. - :vartype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :ivar type_properties_settings_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_settings_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known - values are: "weekly" and "absoluteMonthly". - :vartype type_properties_settings_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "review_history_period_start_date_time": {"readonly": True}, - "review_history_period_end_date_time": {"readonly": True}, - "status": {"readonly": True}, - "created_date_time": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "review_history_period_start_date_time": { - "key": "properties.reviewHistoryPeriodStartDateTime", - "type": "iso-8601", - }, - "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, - "decisions": {"key": "properties.decisions", "type": "[str]"}, - "status": {"key": "properties.status", "type": "str"}, - "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, - "scopes": {"key": "properties.scopes", "type": "[AccessReviewScope]"}, - "instances": {"key": "properties.instances", "type": "[AccessReviewHistoryInstance]"}, - "type_properties_settings_range_type": {"key": "properties.settings.range.type", "type": "str"}, - "number_of_occurrences": {"key": "properties.settings.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.settings.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.settings.range.endDate", "type": "iso-8601"}, - "type_properties_settings_pattern_type": {"key": "properties.settings.pattern.type", "type": "str"}, - "interval": {"key": "properties.settings.pattern.interval", "type": "int"}, - "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, - "principal_type": {"key": "properties.createdBy.principalType", "type": "str"}, - "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, - scopes: Optional[List["_models.AccessReviewScope"]] = None, - instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, - type_properties_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the history definition. - :paramtype display_name: str - :keyword decisions: Collection of review decisions which the history data should be filtered - on. For example if Approve and Deny are supplied the data will only contain review results in - which the decision maker approved or denied a review request. - :paramtype decisions: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] - :keyword scopes: A collection of scopes used when selecting review history data. - :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] - :keyword instances: Set of access review history instances for this history definition. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :keyword type_properties_settings_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_properties_settings_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_settings_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.review_history_period_start_date_time = None - self.review_history_period_end_date_time = None - self.decisions = decisions - self.status = None - self.created_date_time = None - self.scopes = scopes - self.instances = instances - self.type_properties_settings_range_type = type_properties_settings_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_settings_pattern_type = type_properties_settings_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): - """List of Access Review History Instances. - - :ivar value: Access Review History Definition's Instance list. - :vartype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewHistoryInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewHistoryInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review History Definition's Instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewHistoryDefinitionListResult(_serialization.Model): - """List of Access Review History Definitions. - - :ivar value: Access Review History Definition list. - :vartype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewHistoryDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewHistoryDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review History Definition list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewHistoryDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review History Instances. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the history definition. - :vartype display_name: str - :ivar review_history_period_start_date_time: Date time used when selecting review data, all - reviews included in data start on or after this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_start_date_time: ~datetime.datetime - :ivar review_history_period_end_date_time: Date time used when selecting review data, all - reviews included in data end on or before this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_end_date_time: ~datetime.datetime - :ivar decisions: Collection of review decisions which the history data should be filtered on. - For example if Approve and Deny are supplied the data will only contain review results in which - the decision maker approved or denied a review request. - :vartype decisions: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] - :ivar status: This read-only field specifies the of the requested review history data. This is - either requested, in-progress, done or error. Known values are: "Requested", "InProgress", - "Done", and "Error". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus - :ivar created_date_time: Date time when history definition was created. - :vartype created_date_time: ~datetime.datetime - :ivar scopes: A collection of scopes used when selecting review history data. - :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] - :ivar instances: Set of access review history instances for this history definition. - :vartype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :ivar type_settings_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_settings_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: - "weekly" and "absoluteMonthly". - :vartype type_settings_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "review_history_period_start_date_time": {"readonly": True}, - "review_history_period_end_date_time": {"readonly": True}, - "status": {"readonly": True}, - "created_date_time": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "review_history_period_start_date_time": {"key": "reviewHistoryPeriodStartDateTime", "type": "iso-8601"}, - "review_history_period_end_date_time": {"key": "reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, - "decisions": {"key": "decisions", "type": "[str]"}, - "status": {"key": "status", "type": "str"}, - "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, - "scopes": {"key": "scopes", "type": "[AccessReviewScope]"}, - "instances": {"key": "instances", "type": "[AccessReviewHistoryInstance]"}, - "type_settings_range_type": {"key": "settings.range.type", "type": "str"}, - "number_of_occurrences": {"key": "settings.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "settings.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "settings.range.endDate", "type": "iso-8601"}, - "type_settings_pattern_type": {"key": "settings.pattern.type", "type": "str"}, - "interval": {"key": "settings.pattern.interval", "type": "int"}, - "principal_id": {"key": "createdBy.principalId", "type": "str"}, - "principal_type": {"key": "createdBy.principalType", "type": "str"}, - "principal_name": {"key": "createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, - scopes: Optional[List["_models.AccessReviewScope"]] = None, - instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, - type_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the history definition. - :paramtype display_name: str - :keyword decisions: Collection of review decisions which the history data should be filtered - on. For example if Approve and Deny are supplied the data will only contain review results in - which the decision maker approved or denied a review request. - :paramtype decisions: list[str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] - :keyword scopes: A collection of scopes used when selecting review history data. - :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] - :keyword instances: Set of access review history instances for this history definition. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] - :keyword type_settings_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_settings_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :paramtype type_settings_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.display_name = display_name - self.review_history_period_start_date_time = None - self.review_history_period_end_date_time = None - self.decisions = decisions - self.status = None - self.created_date_time = None - self.scopes = scopes - self.instances = instances - self.type_settings_range_type = type_settings_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_settings_pattern_type = type_settings_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewHistoryInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review History Definition Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review history definition instance id. - :vartype id: str - :ivar name: The access review history definition instance unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar review_history_period_start_date_time: Date time used when selecting review data, all - reviews included in data start on or after this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_start_date_time: ~datetime.datetime - :ivar review_history_period_end_date_time: Date time used when selecting review data, all - reviews included in data end on or before this date. For use only with one-time/non-recurring - reports. - :vartype review_history_period_end_date_time: ~datetime.datetime - :ivar display_name: The display name for the parent history definition. - :vartype display_name: str - :ivar status: Status of the requested review history instance data. This is either requested, - in-progress, done or error. The state transitions are as follows - Requested -> InProgress -> - Done -> Expired. Known values are: "Requested", "InProgress", "Done", and "Error". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus - :ivar run_date_time: Date time when the history data report is scheduled to be generated. - :vartype run_date_time: ~datetime.datetime - :ivar fulfilled_date_time: Date time when the history data report is scheduled to be generated. - :vartype fulfilled_date_time: ~datetime.datetime - :ivar download_uri: Uri which can be used to retrieve review history data. To generate this - Uri, generateDownloadUri() must be called for a specific accessReviewHistoryDefinitionInstance. - The link expires after a 24 hour period. Callers can see the expiration date time by looking at - the 'se' parameter in the generated uri. - :vartype download_uri: str - :ivar expiration: Date time when history data report expires and the associated data is - deleted. - :vartype expiration: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "download_uri": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "review_history_period_start_date_time": { - "key": "properties.reviewHistoryPeriodStartDateTime", - "type": "iso-8601", - }, - "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "run_date_time": {"key": "properties.runDateTime", "type": "iso-8601"}, - "fulfilled_date_time": {"key": "properties.fulfilledDateTime", "type": "iso-8601"}, - "download_uri": {"key": "properties.downloadUri", "type": "str"}, - "expiration": {"key": "properties.expiration", "type": "iso-8601"}, - } - - def __init__( - self, - *, - review_history_period_start_date_time: Optional[datetime.datetime] = None, - review_history_period_end_date_time: Optional[datetime.datetime] = None, - display_name: Optional[str] = None, - run_date_time: Optional[datetime.datetime] = None, - fulfilled_date_time: Optional[datetime.datetime] = None, - expiration: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword review_history_period_start_date_time: Date time used when selecting review data, all - reviews included in data start on or after this date. For use only with one-time/non-recurring - reports. - :paramtype review_history_period_start_date_time: ~datetime.datetime - :keyword review_history_period_end_date_time: Date time used when selecting review data, all - reviews included in data end on or before this date. For use only with one-time/non-recurring - reports. - :paramtype review_history_period_end_date_time: ~datetime.datetime - :keyword display_name: The display name for the parent history definition. - :paramtype display_name: str - :keyword run_date_time: Date time when the history data report is scheduled to be generated. - :paramtype run_date_time: ~datetime.datetime - :keyword fulfilled_date_time: Date time when the history data report is scheduled to be - generated. - :paramtype fulfilled_date_time: ~datetime.datetime - :keyword expiration: Date time when history data report expires and the associated data is - deleted. - :paramtype expiration: ~datetime.datetime - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.review_history_period_start_date_time = review_history_period_start_date_time - self.review_history_period_end_date_time = review_history_period_end_date_time - self.display_name = display_name - self.status = None - self.run_date_time = run_date_time - self.fulfilled_date_time = fulfilled_date_time - self.download_uri = None - self.expiration = expiration - - -class AccessReviewInstance(_serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - - -class AccessReviewInstanceListResult(_serialization.Model): - """List of Access Review Instances. - - :ivar value: Access Review Instance list. - :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewInstance]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewInstance"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Instance list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewInstanceProperties(_serialization.Model): - """Access Review Instance properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: This read-only field specifies the status of an access review instance. Known - values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus - :ivar start_date_time: The DateTime when the review instance is scheduled to be start. - :vartype start_date_time: ~datetime.datetime - :ivar end_date_time: The DateTime when the review instance is scheduled to end. - :vartype end_date_time: ~datetime.datetime - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - end_date_time: Optional[datetime.datetime] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: The DateTime when the review instance is scheduled to be start. - :paramtype start_date_time: ~datetime.datetime - :keyword end_date_time: The DateTime when the review instance is scheduled to end. - :paramtype end_date_time: ~datetime.datetime - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - """ - super().__init__(**kwargs) - self.status = None - self.start_date_time = start_date_time - self.end_date_time = end_date_time - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - - -class AccessReviewReviewer(_serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The id of the reviewer(user/servicePrincipal). - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and - "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - "principal_type": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: The id of the reviewer(user/servicePrincipal). - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.principal_type = None - - -class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and - "redeemedGuestUser". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. - :vartype expand_nested_memberships: bool - :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. - :vartype include_inherited_access: bool - :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or - not. - :vartype include_access_below_resource: bool - :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :vartype exclude_resource_id: str - :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :vartype exclude_role_definition_id: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Known values are: "weekly" and "absoluteMonthly". - :vartype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Known values are: "user" and "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_properties_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_properties_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, - "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, - "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, - "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, - "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, - "include_inherited_access": {"key": "properties.scope.includeInheritedAccess", "type": "bool"}, - "include_access_below_resource": {"key": "properties.scope.includeAccessBelowResource", "type": "bool"}, - "exclude_resource_id": {"key": "properties.scope.excludeResourceId", "type": "str"}, - "exclude_role_definition_id": {"key": "properties.scope.excludeRoleDefinitionId", "type": "str"}, - "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": { - "key": "properties.settings.justificationRequiredOnApproval", - "type": "bool", - }, - "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": { - "key": "properties.settings.recommendationLookBackDuration", - "type": "duration", - }, - "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, - "type_properties_settings_recurrence_range_type": { - "key": "properties.settings.recurrence.range.type", - "type": "str", - }, - "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_properties_settings_recurrence_pattern_type": { - "key": "properties.settings.recurrence.pattern.type", - "type": "str", - }, - "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, - "principal_type_properties_created_by_principal_type": { - "key": "properties.createdBy.principalType", - "type": "str", - }, - "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - expand_nested_memberships: Optional[bool] = None, - include_inherited_access: Optional[bool] = None, - include_access_below_resource: Optional[bool] = None, - exclude_resource_id: Optional[str] = None, - exclude_role_definition_id: Optional[str] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_properties_settings_recurrence_range_type: Optional[ - Union[str, "_models.AccessReviewRecurrenceRangeType"] - ] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_properties_settings_recurrence_pattern_type: Optional[ - Union[str, "_models.AccessReviewRecurrencePatternType"] - ] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or - not. - :paramtype expand_nested_memberships: bool - :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or - not. - :paramtype include_inherited_access: bool - :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships - or not. - :paramtype include_access_below_resource: bool - :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :paramtype exclude_resource_id: str - :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :paramtype exclude_role_definition_id: str - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The - possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and - "numbered". - :paramtype type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, - monthly, etc. Known values are: "weekly" and "absoluteMonthly". - :paramtype type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.expand_nested_memberships = expand_nested_memberships - self.include_inherited_access = include_inherited_access - self.include_access_below_resource = include_access_below_resource - self.exclude_resource_id = exclude_resource_id - self.exclude_role_definition_id = exclude_role_definition_id - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(_serialization.Model): - """List of Access Review Schedule Definitions. - - :ivar value: Access Review Schedule Definition list. - :vartype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Access Review Schedule Definition list. - :paramtype value: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar display_name: The display name for the schedule definition. - :vartype display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Known values are: - "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", - "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus - :ivar description_for_admins: The description provided by the access review creator and visible - to admins. - :vartype description_for_admins: str - :ivar description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :vartype description_for_reviewers: str - :ivar reviewers: This is the collection of reviewers. - :vartype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar backup_reviewers: This is the collection of backup reviewers. - :vartype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: 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. Known - values are: "Assigned", "Self", and "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :ivar instances: This is the collection of instances returned when one does an expand on it. - :vartype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Known values are: "user", "guestUser", "servicePrincipal", "user,group", and - "redeemedGuestUser". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. - :vartype expand_nested_memberships: bool - :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. - :vartype include_inherited_access: bool - :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or - not. - :vartype include_access_below_resource: bool - :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :vartype exclude_resource_id: str - :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :vartype exclude_role_definition_id: str - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known - values are: "weekly" and "absoluteMonthly". - :vartype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Known values are: "user" and "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - "status": {"readonly": True}, - "reviewers_type": {"readonly": True}, - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type_scope_principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - "principal_id": {"readonly": True}, - "principal_type_created_by_principal_type": {"readonly": True}, - "principal_name": {"readonly": True}, - "user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, - "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, - "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, - "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, - "reviewers_type": {"key": "reviewersType", "type": "str"}, - "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, - "resource_id": {"key": "scope.resourceId", "type": "str"}, - "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, - "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, - "assignment_state": {"key": "scope.assignmentState", "type": "str"}, - "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, - "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, - "include_inherited_access": {"key": "scope.includeInheritedAccess", "type": "bool"}, - "include_access_below_resource": {"key": "scope.includeAccessBelowResource", "type": "bool"}, - "exclude_resource_id": {"key": "scope.excludeResourceId", "type": "str"}, - "exclude_role_definition_id": {"key": "scope.excludeRoleDefinitionId", "type": "str"}, - "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "settings.defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, - "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, - "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, - "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, - "principal_id": {"key": "createdBy.principalId", "type": "str"}, - "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, - "principal_name": {"key": "createdBy.principalName", "type": "str"}, - "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - display_name: Optional[str] = None, - description_for_admins: Optional[str] = None, - description_for_reviewers: Optional[str] = None, - reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, - instances: Optional[List["_models.AccessReviewInstance"]] = None, - inactive_duration: Optional[datetime.timedelta] = None, - expand_nested_memberships: Optional[bool] = None, - include_inherited_access: Optional[bool] = None, - include_access_below_resource: Optional[bool] = None, - exclude_resource_id: Optional[str] = None, - exclude_role_definition_id: Optional[str] = None, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: The display name for the schedule definition. - :paramtype display_name: str - :keyword description_for_admins: The description provided by the access review creator and - visible to admins. - :paramtype description_for_admins: str - :keyword description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :paramtype description_for_reviewers: str - :keyword reviewers: This is the collection of reviewers. - :paramtype reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword backup_reviewers: This is the collection of backup reviewers. - :paramtype backup_reviewers: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] - :keyword instances: This is the collection of instances returned when one does an expand on it. - :paramtype instances: - list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or - not. - :paramtype expand_nested_memberships: bool - :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or - not. - :paramtype include_inherited_access: bool - :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships - or not. - :paramtype include_access_below_resource: bool - :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :paramtype exclude_resource_id: str - :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :paramtype exclude_role_definition_id: str - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Known values are: "weekly" and "absoluteMonthly". - :paramtype type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.display_name = display_name - self.status = None - self.description_for_admins = description_for_admins - self.description_for_reviewers = description_for_reviewers - self.reviewers = reviewers - self.backup_reviewers = backup_reviewers - self.reviewers_type = None - self.instances = instances - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.expand_nested_memberships = expand_nested_memberships - self.include_inherited_access = include_inherited_access - self.include_access_below_resource = include_access_below_resource - self.exclude_resource_id = exclude_resource_id - self.exclude_role_definition_id = exclude_role_definition_id - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_settings_recurrence_range_type = type_settings_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type - self.interval = interval - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Settings of an Access Review. - - :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :vartype mail_notifications_enabled: bool - :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :vartype reminder_notifications_enabled: bool - :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :vartype default_decision_enabled: bool - :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :vartype justification_required_on_approval: bool - :ivar default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Known values are: "Approve", "Deny", and "Recommendation". - :vartype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :ivar auto_apply_decisions_enabled: 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. - :vartype auto_apply_decisions_enabled: bool - :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is - enabled. - :vartype recommendations_enabled: bool - :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by - looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :vartype recommendation_look_back_duration: ~datetime.timedelta - :ivar instance_duration_in_days: The duration in days for an instance. - :vartype instance_duration_in_days: int - :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :vartype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :ivar number_of_occurrences: The number of times to repeat the access review. Required and must - be positive if type is numbered. - :vartype number_of_occurrences: int - :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :vartype start_date: ~datetime.datetime - :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :vartype end_date: ~datetime.datetime - :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :vartype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type - : absoluteMonthly. - :vartype interval: int - """ - - _attribute_map = { - "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, - "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, - "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, - "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, - "default_decision": {"key": "defaultDecision", "type": "str"}, - "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, - "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, - "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, - "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, - "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, - "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, - "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, - "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, - "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, - "interval": {"key": "recurrence.pattern.interval", "type": "int"}, - } - - def __init__( - self, - *, - mail_notifications_enabled: Optional[bool] = None, - reminder_notifications_enabled: Optional[bool] = None, - default_decision_enabled: Optional[bool] = None, - justification_required_on_approval: Optional[bool] = None, - default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, - auto_apply_decisions_enabled: Optional[bool] = None, - recommendations_enabled: Optional[bool] = None, - recommendation_look_back_duration: Optional[datetime.timedelta] = None, - instance_duration_in_days: Optional[int] = None, - type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, - number_of_occurrences: Optional[int] = None, - start_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, - interval: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and - the review creator is enabled. - :paramtype mail_notifications_enabled: bool - :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :paramtype reminder_notifications_enabled: bool - :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :paramtype default_decision_enabled: bool - :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required - to pass justification when recording a decision. - :paramtype justification_required_on_approval: bool - :keyword default_decision: This specifies the behavior for the autoReview feature when an - access review completes. Known values are: "Approve", "Deny", and "Recommendation". - :paramtype default_decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType - :keyword auto_apply_decisions_enabled: 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. - :paramtype auto_apply_decisions_enabled: bool - :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :paramtype recommendations_enabled: bool - :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated - by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in - some scenarios, customers want to change how far back to look at and want to configure 60 days, - 90 days, etc. instead. This setting allows customers to configure this duration. The value - should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can - be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, - minutes, seconds)). - :paramtype recommendation_look_back_duration: ~datetime.timedelta - :keyword instance_duration_in_days: The duration in days for an instance. - :paramtype instance_duration_in_days: int - :keyword type_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". - :paramtype type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType - :keyword number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :paramtype number_of_occurrences: int - :keyword start_date: The DateTime when the review is scheduled to be start. This could be a - date in the future. Required on create. - :paramtype start_date: ~datetime.datetime - :keyword end_date: The DateTime when the review is scheduled to end. Required if type is - endDate. - :paramtype end_date: ~datetime.datetime - :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values - are: "weekly" and "absoluteMonthly". - :paramtype type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType - :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :paramtype interval: int - """ - super().__init__(**kwargs) - self.mail_notifications_enabled = mail_notifications_enabled - self.reminder_notifications_enabled = reminder_notifications_enabled - self.default_decision_enabled = default_decision_enabled - self.justification_required_on_approval = justification_required_on_approval - self.default_decision = default_decision - self.auto_apply_decisions_enabled = auto_apply_decisions_enabled - self.recommendations_enabled = recommendations_enabled - self.recommendation_look_back_duration = recommendation_look_back_duration - self.instance_duration_in_days = instance_duration_in_days - self.type_recurrence_range_type = type_recurrence_range_type - self.number_of_occurrences = number_of_occurrences - self.start_date = start_date - self.end_date = end_date - self.type_recurrence_pattern_type = type_recurrence_pattern_type - self.interval = interval - - -class AccessReviewScope(_serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type: The identity type user/servicePrincipal to review. Known values are: - "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Known values are: - "eligible" and "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState - :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :vartype inactive_duration: ~datetime.timedelta - :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. - :vartype expand_nested_memberships: bool - :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. - :vartype include_inherited_access: bool - :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or - not. - :vartype include_access_below_resource: bool - :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :vartype exclude_resource_id: str - :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :vartype exclude_role_definition_id: str - """ - - _validation = { - "resource_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "principal_type": {"readonly": True}, - "assignment_state": {"readonly": True}, - } - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "principal_type": {"key": "principalType", "type": "str"}, - "assignment_state": {"key": "assignmentState", "type": "str"}, - "inactive_duration": {"key": "inactiveDuration", "type": "duration"}, - "expand_nested_memberships": {"key": "expandNestedMemberships", "type": "bool"}, - "include_inherited_access": {"key": "includeInheritedAccess", "type": "bool"}, - "include_access_below_resource": {"key": "includeAccessBelowResource", "type": "bool"}, - "exclude_resource_id": {"key": "excludeResourceId", "type": "str"}, - "exclude_role_definition_id": {"key": "excludeRoleDefinitionId", "type": "str"}, - } - - def __init__( - self, - *, - inactive_duration: Optional[datetime.timedelta] = None, - expand_nested_memberships: Optional[bool] = None, - include_inherited_access: Optional[bool] = None, - include_access_below_resource: Optional[bool] = None, - exclude_resource_id: Optional[str] = None, - exclude_role_definition_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :paramtype inactive_duration: ~datetime.timedelta - :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or - not. - :paramtype expand_nested_memberships: bool - :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or - not. - :paramtype include_inherited_access: bool - :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships - or not. - :paramtype include_access_below_resource: bool - :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. - :paramtype exclude_resource_id: str - :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to - exclude. - :paramtype exclude_role_definition_id: str - """ - super().__init__(**kwargs) - self.resource_id = None - self.role_definition_id = None - self.principal_type = None - self.assignment_state = None - self.inactive_duration = inactive_duration - self.expand_nested_memberships = expand_nested_memberships - self.include_inherited_access = include_inherited_access - self.include_access_below_resource = include_access_below_resource - self.exclude_resource_id = exclude_resource_id - self.exclude_role_definition_id = exclude_role_definition_id - - -class ErrorDefinition(_serialization.Model): - """Error description and code explaining why an operation failed. - - :ivar error: Error of the list gateway status. - :vartype error: ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionProperties"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error of the list gateway status. - :paramtype error: - ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorDefinitionProperties(_serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :ivar code: Error code of list gateway. - :vartype code: str - """ - - _validation = { - "message": {"readonly": True}, - } - - _attribute_map = { - "message": {"key": "message", "type": "str"}, - "code": {"key": "code", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code of list gateway. - :paramtype code: str - """ - super().__init__(**kwargs) - self.message = None - self.code = code - - -class Operation(_serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :ivar name: Name of the operation. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: Display of the operation. - :vartype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay - :ivar origin: Origin of the operation. - :vartype origin: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the operation. - :paramtype name: str - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: Display of the operation. - :paramtype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay - :keyword origin: Origin of the operation. - :paramtype origin: str - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = is_data_action - self.display = display - self.origin = origin - - -class OperationDisplay(_serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The collection value. - :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] - :keyword next_link: The URI that can be used to request the next set of paged results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RecordAllDecisionsProperties(_serialization.Model): - """Record All Decisions payload. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The id of principal which needs to be approved/denied. - :vartype principal_id: str - :ivar resource_id: The id of resource which needs to be approved/denied. - :vartype resource_id: str - :ivar decision: The decision to make. Approvers can take action of Approve/Deny. Known values - are: "Approve" and "Deny". - :vartype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult - :ivar justification: Justification provided by approvers for their action. - :vartype justification: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "resource_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "decision": {"key": "decision", "type": "str"}, - "justification": {"key": "justification", "type": "str"}, - } - - def __init__( - self, - *, - decision: Optional[Union[str, "_models.RecordAllDecisionsResult"]] = None, - justification: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword decision: The decision to make. Approvers can take action of Approve/Deny. Known - values are: "Approve" and "Deny". - :paramtype decision: str or - ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult - :keyword justification: Justification provided by approvers for their action. - :paramtype justification: str - """ - super().__init__(**kwargs) - self.principal_id = None - self.resource_id = None - self.decision = decision - self.justification = justification diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/__init__.py deleted file mode 100644 index d04d147885dc..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._operations import Operations -from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations -from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations -from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations -from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations -from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations -from ._access_review_instances_operations import AccessReviewInstancesOperations -from ._access_review_instance_operations import AccessReviewInstanceOperations -from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations -from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations -from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations -from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations -from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations -from ._scope_access_review_history_definition_instance_operations import ( - ScopeAccessReviewHistoryDefinitionInstanceOperations, -) -from ._scope_access_review_history_definition_instances_operations import ( - ScopeAccessReviewHistoryDefinitionInstancesOperations, -) -from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations -from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations -from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations -from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations -from ._scope_access_review_instance_contacted_reviewers_operations import ( - ScopeAccessReviewInstanceContactedReviewersOperations, -) -from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations -from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( - AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, -) -from ._access_review_instances_assigned_for_my_approval_operations import ( - AccessReviewInstancesAssignedForMyApprovalOperations, -) -from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations -from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( - TenantLevelAccessReviewInstanceContactedReviewersOperations, -) - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "AccessReviewHistoryDefinitionsOperations", - "AccessReviewHistoryDefinitionOperations", - "AccessReviewHistoryDefinitionInstanceOperations", - "AccessReviewHistoryDefinitionInstancesOperations", - "AccessReviewScheduleDefinitionsOperations", - "AccessReviewInstancesOperations", - "AccessReviewInstanceOperations", - "AccessReviewInstanceDecisionsOperations", - "AccessReviewInstanceContactedReviewersOperations", - "AccessReviewDefaultSettingsOperations", - "ScopeAccessReviewHistoryDefinitionsOperations", - "ScopeAccessReviewHistoryDefinitionOperations", - "ScopeAccessReviewHistoryDefinitionInstanceOperations", - "ScopeAccessReviewHistoryDefinitionInstancesOperations", - "ScopeAccessReviewScheduleDefinitionsOperations", - "ScopeAccessReviewInstancesOperations", - "ScopeAccessReviewInstanceOperations", - "ScopeAccessReviewInstanceDecisionsOperations", - "ScopeAccessReviewInstanceContactedReviewersOperations", - "ScopeAccessReviewDefaultSettingsOperations", - "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", - "AccessReviewInstancesAssignedForMyApprovalOperations", - "AccessReviewInstanceMyDecisionsOperations", - "TenantLevelAccessReviewInstanceContactedReviewersOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_12_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py deleted file mode 100644 index 048a0e100390..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_authorization_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - DenyAssignmentsOperations, - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to get deny - assignments. A deny assignment describes the set of actions on resources that are denied for - Azure Active Directory users. - - :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: - azure.mgmt.authorization.v2022_04_01.operations.DenyAssignmentsOperations - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2022_04_01.operations.ProviderOperationsMetadataOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2022_04_01.operations.RoleAssignmentsOperations - :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2022_04_01.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2022_04_01.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py deleted file mode 100644 index b501f5692f43..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json deleted file mode 100644 index 1ded4f59232d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2022-04-01", - "total_api_version_list": ["2022-04-01"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "deny_assignments": "DenyAssignmentsOperations", - "provider_operations_metadata": "ProviderOperationsMetadataOperations", - "role_assignments": "RoleAssignmentsOperations", - "permissions": "PermissionsOperations", - "role_definitions": "RoleDefinitionsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py deleted file mode 100644 index c742c42451a6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_authorization_management_client.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - DenyAssignmentsOperations, - PermissionsOperations, - ProviderOperationsMetadataOperations, - RoleAssignmentsOperations, - RoleDefinitionsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to get deny - assignments. A deny assignment describes the set of actions on resources that are denied for - Azure Active Directory users. - - :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: - azure.mgmt.authorization.v2022_04_01.aio.operations.DenyAssignmentsOperations - :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: - azure.mgmt.authorization.v2022_04_01.aio.operations.ProviderOperationsMetadataOperations - :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: - azure.mgmt.authorization.v2022_04_01.aio.operations.RoleAssignmentsOperations - :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2022_04_01.aio.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2022_04_01.aio.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py deleted file mode 100644 index f778747ea8b4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/__init__.py deleted file mode 100644 index 336442a84fe5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._deny_assignments_operations import DenyAssignmentsOperations -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DenyAssignmentsOperations", - "ProviderOperationsMetadataOperations", - "RoleAssignmentsOperations", - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py deleted file mode 100644 index 93f5baf144c1..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_permissions_operations.py +++ /dev/null @@ -1,250 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.aio.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py deleted file mode 100644 index 938ae96af886..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_provider_operations_metadata_operations.py +++ /dev/null @@ -1,201 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._provider_operations_metadata_operations import build_get_request, build_list_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProviderOperationsMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.aio.AuthorizationManagementClient`'s - :attr:`provider_operations_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def get( - self, resource_provider_namespace: str, expand: str = "resourceTypes", **kwargs: Any - ) -> _models.ProviderOperationsMetadata: - """Gets provider operations metadata for the specified resource provider. - - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProviderOperationsMetadata or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.ProviderOperationsMetadata] = kwargs.pop("cls", None) - - request = build_get_request( - resource_provider_namespace=resource_provider_namespace, - expand=expand, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ProviderOperationsMetadata", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} - - @distributed_trace - def list(self, expand: str = "resourceTypes", **kwargs: Any) -> AsyncIterable["_models.ProviderOperationsMetadata"]: - """Gets provider operations metadata for all resource providers. - - :param expand: Specifies whether to expand the values. Default value is "resourceTypes". - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadata or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.ProviderOperationsMetadataListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - expand=expand, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Authorization/providerOperations"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py deleted file mode 100644 index 4531a6c139d4..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/aio/operations/_role_definitions_operations.py +++ /dev/null @@ -1,463 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_definitions_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_by_id_request, - build_get_request, - build_list_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.aio.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace_async - async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace_async - async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace_async - async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_id: 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. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/__init__.py deleted file mode 100644 index 198470fcd79b..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/__init__.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ApprovalSettings -from ._models_py3 import ApprovalStage -from ._models_py3 import DenyAssignment -from ._models_py3 import DenyAssignmentFilter -from ._models_py3 import DenyAssignmentListResult -from ._models_py3 import DenyAssignmentPermission -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Permission -from ._models_py3 import PermissionGetResult -from ._models_py3 import Principal -from ._models_py3 import ProviderOperation -from ._models_py3 import ProviderOperationsMetadata -from ._models_py3 import ProviderOperationsMetadataListResult -from ._models_py3 import ResourceType -from ._models_py3 import RoleAssignment -from ._models_py3 import RoleAssignmentCreateParameters -from ._models_py3 import RoleAssignmentFilter -from ._models_py3 import RoleAssignmentListResult -from ._models_py3 import RoleDefinition -from ._models_py3 import RoleDefinitionFilter -from ._models_py3 import RoleDefinitionListResult -from ._models_py3 import RoleManagementPolicyApprovalRule -from ._models_py3 import RoleManagementPolicyAuthenticationContextRule -from ._models_py3 import RoleManagementPolicyEnablementRule -from ._models_py3 import RoleManagementPolicyExpirationRule -from ._models_py3 import RoleManagementPolicyNotificationRule -from ._models_py3 import RoleManagementPolicyRule -from ._models_py3 import RoleManagementPolicyRuleTarget -from ._models_py3 import UserSet -from ._models_py3 import ValidationResponse -from ._models_py3 import ValidationResponseErrorInfo - -from ._authorization_management_client_enums import ApprovalMode -from ._authorization_management_client_enums import EnablementRules -from ._authorization_management_client_enums import NotificationDeliveryMechanism -from ._authorization_management_client_enums import NotificationLevel -from ._authorization_management_client_enums import PrincipalType -from ._authorization_management_client_enums import RecipientType -from ._authorization_management_client_enums import RoleManagementPolicyRuleType -from ._authorization_management_client_enums import UserType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApprovalSettings", - "ApprovalStage", - "DenyAssignment", - "DenyAssignmentFilter", - "DenyAssignmentListResult", - "DenyAssignmentPermission", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Permission", - "PermissionGetResult", - "Principal", - "ProviderOperation", - "ProviderOperationsMetadata", - "ProviderOperationsMetadataListResult", - "ResourceType", - "RoleAssignment", - "RoleAssignmentCreateParameters", - "RoleAssignmentFilter", - "RoleAssignmentListResult", - "RoleDefinition", - "RoleDefinitionFilter", - "RoleDefinitionListResult", - "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule", - "RoleManagementPolicyRule", - "RoleManagementPolicyRuleTarget", - "UserSet", - "ValidationResponse", - "ValidationResponseErrorInfo", - "ApprovalMode", - "EnablementRules", - "NotificationDeliveryMechanism", - "NotificationLevel", - "PrincipalType", - "RecipientType", - "RoleManagementPolicyRuleType", - "UserType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_authorization_management_client_enums.py deleted file mode 100644 index b479e5120c47..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - SINGLE_STAGE = "SingleStage" - SERIAL = "Serial" - PARALLEL = "Parallel" - NO_APPROVAL = "NoApproval" - - -class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of enablement rule.""" - - MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" - JUSTIFICATION = "Justification" - TICKETING = "Ticketing" - - -class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of notification.""" - - EMAIL = "Email" - - -class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The notification level.""" - - NONE = "None" - CRITICAL = "Critical" - ALL = "All" - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" - DEVICE = "Device" - - -class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recipient type.""" - - REQUESTOR = "Requestor" - APPROVER = "Approver" - ADMIN = "Admin" - - -class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" - ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" - ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" - ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" - ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" - - -class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of user.""" - - USER = "User" - GROUP = "Group" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py deleted file mode 100644 index a25c36472046..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py +++ /dev/null @@ -1,1795 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 sys -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class ApprovalSettings(_serialization.Model): - """The approval settings. - - :ivar is_approval_required: Determines whether approval is required or not. - :vartype is_approval_required: bool - :ivar is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :vartype is_approval_required_for_extension: bool - :ivar is_requestor_justification_required: Determine whether requestor justification is - required. - :vartype is_requestor_justification_required: bool - :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", - and "NoApproval". - :vartype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode - :ivar approval_stages: The approval stages of the request. - :vartype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] - """ - - _attribute_map = { - "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, - "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, - "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, - "approval_mode": {"key": "approvalMode", "type": "str"}, - "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, - } - - def __init__( - self, - *, - is_approval_required: Optional[bool] = None, - is_approval_required_for_extension: Optional[bool] = None, - is_requestor_justification_required: Optional[bool] = None, - approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, - approval_stages: Optional[List["_models.ApprovalStage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_approval_required: Determines whether approval is required or not. - :paramtype is_approval_required: bool - :keyword is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :paramtype is_approval_required_for_extension: bool - :keyword is_requestor_justification_required: Determine whether requestor justification is - required. - :paramtype is_requestor_justification_required: bool - :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", - "Parallel", and "NoApproval". - :paramtype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode - :keyword approval_stages: The approval stages of the request. - :paramtype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] - """ - super().__init__(**kwargs) - self.is_approval_required = is_approval_required - self.is_approval_required_for_extension = is_approval_required_for_extension - self.is_requestor_justification_required = is_requestor_justification_required - self.approval_mode = approval_mode - self.approval_stages = approval_stages - - -class ApprovalStage(_serialization.Model): - """The approval stage. - - :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :vartype approval_stage_time_out_in_days: int - :ivar is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :vartype is_approver_justification_required: bool - :ivar escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :vartype escalation_time_in_minutes: int - :ivar primary_approvers: The primary approver of the request. - :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] - :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. - :vartype is_escalation_enabled: bool - :ivar escalation_approvers: The escalation approver of the request. - :vartype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] - """ - - _attribute_map = { - "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, - "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, - "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, - "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, - "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, - "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, - } - - def __init__( - self, - *, - approval_stage_time_out_in_days: Optional[int] = None, - is_approver_justification_required: Optional[bool] = None, - escalation_time_in_minutes: Optional[int] = None, - primary_approvers: Optional[List["_models.UserSet"]] = None, - is_escalation_enabled: Optional[bool] = None, - escalation_approvers: Optional[List["_models.UserSet"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :paramtype approval_stage_time_out_in_days: int - :keyword is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :paramtype is_approver_justification_required: bool - :keyword escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :paramtype escalation_time_in_minutes: int - :keyword primary_approvers: The primary approver of the request. - :paramtype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] - :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. - :paramtype is_escalation_enabled: bool - :keyword escalation_approvers: The escalation approver of the request. - :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] - """ - super().__init__(**kwargs) - self.approval_stage_time_out_in_days = approval_stage_time_out_in_days - self.is_approver_justification_required = is_approver_justification_required - self.escalation_time_in_minutes = escalation_time_in_minutes - self.primary_approvers = primary_approvers - self.is_escalation_enabled = is_escalation_enabled - self.escalation_approvers = escalation_approvers - - -class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Deny Assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The deny assignment ID. - :vartype id: str - :ivar name: The deny assignment name. - :vartype name: str - :ivar type: The deny assignment type. - :vartype type: str - :ivar deny_assignment_name: The display name of the deny assignment. - :vartype deny_assignment_name: str - :ivar description: The description of the deny assignment. - :vartype description: str - :ivar permissions: An array of permissions that are denied by the deny assignment. - :vartype permissions: - list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] - :ivar scope: The deny assignment scope. - :vartype scope: str - :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. - Default value is false. - :vartype do_not_apply_to_child_scopes: bool - :ivar principals: Array of principals to which the deny assignment applies. - :vartype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] - :ivar exclude_principals: Array of principals to which the deny assignment does not apply. - :vartype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] - :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :vartype is_system_protected: bool - :ivar condition: The conditions on the deny assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :vartype condition: str - :ivar condition_version: Version of the condition. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, - "scope": {"key": "properties.scope", "type": "str"}, - "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, - "principals": {"key": "properties.principals", "type": "[Principal]"}, - "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, - "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - } - - def __init__( - self, - *, - deny_assignment_name: Optional[str] = None, - description: Optional[str] = None, - permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, - scope: Optional[str] = None, - do_not_apply_to_child_scopes: Optional[bool] = None, - principals: Optional[List["_models.Principal"]] = None, - exclude_principals: Optional[List["_models.Principal"]] = None, - is_system_protected: Optional[bool] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword deny_assignment_name: The display name of the deny assignment. - :paramtype deny_assignment_name: str - :keyword description: The description of the deny assignment. - :paramtype description: str - :keyword permissions: An array of permissions that are denied by the deny assignment. - :paramtype permissions: - list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] - :keyword scope: The deny assignment scope. - :paramtype scope: str - :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child - scopes. Default value is false. - :paramtype do_not_apply_to_child_scopes: bool - :keyword principals: Array of principals to which the deny assignment applies. - :paramtype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] - :keyword exclude_principals: Array of principals to which the deny assignment does not apply. - :paramtype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] - :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :paramtype is_system_protected: bool - :keyword condition: The conditions on the deny assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :paramtype condition: str - :keyword condition_version: Version of the condition. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.deny_assignment_name = deny_assignment_name - self.description = description - self.permissions = permissions - self.scope = scope - self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes - self.principals = principals - self.exclude_principals = exclude_principals - self.is_system_protected = is_system_protected - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - - -class DenyAssignmentFilter(_serialization.Model): - """Deny Assignments filter. - - :ivar deny_assignment_name: Return deny assignment with specified name. - :vartype deny_assignment_name: str - :ivar principal_id: Return all deny assignments where the specified principal is listed in the - principals list of deny assignments. - :vartype principal_id: str - :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is - listed either in the principals list or exclude principals list of deny assignments. - :vartype gdpr_export_principal_id: str - """ - - _attribute_map = { - "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, - } - - def __init__( - self, - *, - deny_assignment_name: Optional[str] = None, - principal_id: Optional[str] = None, - gdpr_export_principal_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword deny_assignment_name: Return deny assignment with specified name. - :paramtype deny_assignment_name: str - :keyword principal_id: Return all deny assignments where the specified principal is listed in - the principals list of deny assignments. - :paramtype principal_id: str - :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is - listed either in the principals list or exclude principals list of deny assignments. - :paramtype gdpr_export_principal_id: str - """ - super().__init__(**kwargs) - self.deny_assignment_name = deny_assignment_name - self.principal_id = principal_id - self.gdpr_export_principal_id = gdpr_export_principal_id - - -class DenyAssignmentListResult(_serialization.Model): - """Deny assignment list operation result. - - :ivar value: Deny assignment list. - :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DenyAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Deny assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DenyAssignmentPermission(_serialization.Model): - """Deny assignment permissions. - - :ivar actions: Actions to which the deny assignment does not grant access. - :vartype actions: list[str] - :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. - :vartype not_actions: list[str] - :ivar data_actions: Data actions to which the deny assignment does not grant access. - :vartype data_actions: list[str] - :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :vartype not_data_actions: list[str] - :ivar condition: The conditions on the Deny assignment permission. This limits the resources it - applies to. - :vartype condition: str - :ivar condition_version: Version of the condition. - :vartype condition_version: str - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - "condition": {"key": "condition", "type": "str"}, - "condition_version": {"key": "conditionVersion", "type": "str"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Actions to which the deny assignment does not grant access. - :paramtype actions: list[str] - :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. - :paramtype not_actions: list[str] - :keyword data_actions: Data actions to which the deny assignment does not grant access. - :paramtype data_actions: list[str] - :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :paramtype not_data_actions: list[str] - :keyword condition: The conditions on the Deny assignment permission. This limits the resources - it applies to. - :paramtype condition: str - :keyword condition_version: Version of the condition. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - self.condition = condition - self.condition_version = condition_version - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2022_04_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Permission(_serialization.Model): - """Role definition permissions. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - """ - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - - -class PermissionGetResult(_serialization.Model): - """Permissions information. - - :ivar value: An array of permissions. - :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Permission]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: An array of permissions. - :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Principal(_serialization.Model): - """The name of the entity last modified it. - - :ivar id: The id of the principal made changes. - :vartype id: str - :ivar display_name: The name of the principal made changes. - :vartype display_name: str - :ivar type: Type of principal such as user , group etc. - :vartype type: str - :ivar email: Email of principal. - :vartype email: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - email: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the principal made changes. - :paramtype id: str - :keyword display_name: The name of the principal made changes. - :paramtype display_name: str - :keyword type: Type of principal such as user , group etc. - :paramtype type: str - :keyword email: Email of principal. - :paramtype email: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - self.email = email - - -class ProviderOperation(_serialization.Model): - """Operation. - - :ivar name: The operation name. - :vartype name: str - :ivar display_name: The operation display name. - :vartype display_name: str - :ivar description: The operation description. - :vartype description: str - :ivar origin: The operation origin. - :vartype origin: str - :ivar properties: The operation properties. - :vartype properties: JSON - :ivar is_data_action: The dataAction flag to specify the operation type. - :vartype is_data_action: bool - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "object"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - description: Optional[str] = None, - origin: Optional[str] = None, - properties: Optional[JSON] = None, - is_data_action: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The operation name. - :paramtype name: str - :keyword display_name: The operation display name. - :paramtype display_name: str - :keyword description: The operation description. - :paramtype description: str - :keyword origin: The operation origin. - :paramtype origin: str - :keyword properties: The operation properties. - :paramtype properties: JSON - :keyword is_data_action: The dataAction flag to specify the operation type. - :paramtype is_data_action: bool - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.description = description - self.origin = origin - self.properties = properties - self.is_data_action = is_data_action - - -class ProviderOperationsMetadata(_serialization.Model): - """Provider Operations metadata. - - :ivar id: The provider id. - :vartype id: str - :ivar name: The provider name. - :vartype name: str - :ivar type: The provider type. - :vartype type: str - :ivar display_name: The provider display name. - :vartype display_name: str - :ivar resource_types: The provider resource types. - :vartype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] - :ivar operations: The provider operations. - :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - display_name: Optional[str] = None, - resource_types: Optional[List["_models.ResourceType"]] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The provider id. - :paramtype id: str - :keyword name: The provider name. - :paramtype name: str - :keyword type: The provider type. - :paramtype type: str - :keyword display_name: The provider display name. - :paramtype display_name: str - :keyword resource_types: The provider resource types. - :paramtype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] - :keyword operations: The provider operations. - :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.display_name = display_name - self.resource_types = resource_types - self.operations = operations - - -class ProviderOperationsMetadataListResult(_serialization.Model): - """Provider operations metadata list. - - :ivar value: The list of providers. - :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ProviderOperationsMetadata"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The list of providers. - :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResourceType(_serialization.Model): - """Resource Type. - - :ivar name: The resource type name. - :vartype name: str - :ivar display_name: The resource type display name. - :vartype display_name: str - :ivar operations: The resource type operations. - :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "operations": {"key": "operations", "type": "[ProviderOperation]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - operations: Optional[List["_models.ProviderOperation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The resource type name. - :paramtype name: str - :keyword display_name: The resource type display name. - :paramtype display_name: str - :keyword operations: The resource type operations. - :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.operations = operations - - -class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - principal_type: Union[str, "_models.PrincipalType"] = "User", - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently the only accepted value is - '2.0'. - :paramtype condition_version: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.description = description - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role assignment create parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar scope: The role assignment scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. Required. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. Required. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType - :ivar description: Description of role assignment. - :vartype description: str - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :vartype delegated_managed_identity_resource_id: str - """ - - _validation = { - "scope": {"readonly": True}, - "role_definition_id": {"required": True}, - "principal_id": {"required": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - "delegated_managed_identity_resource_id": { - "key": "properties.delegatedManagedIdentityResourceId", - "type": "str", - }, - } - - def __init__( - self, - *, - role_definition_id: str, - principal_id: str, - principal_type: Union[str, "_models.PrincipalType"] = "User", - description: Optional[str] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - delegated_managed_identity_resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. Required. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. Required. - :paramtype principal_id: str - :keyword principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType - :keyword description: Description of role assignment. - :paramtype description: str - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently the only accepted value is - '2.0'. - :paramtype condition_version: str - :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :paramtype delegated_managed_identity_resource_id: str - """ - super().__init__(**kwargs) - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = principal_type - self.description = description - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id - - -class RoleAssignmentFilter(_serialization.Model): - """Role Assignments filter. - - :ivar principal_id: Returns role assignment of the specific principal. - :vartype principal_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: Returns role assignment of the specific principal. - :paramtype principal_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - - -class RoleAssignmentListResult(_serialization.Model): - """Role assignment list operation result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Role assignment list. - :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] - :ivar next_link: The skipToken to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Role assignment list. - :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :ivar role_name: The role name. - :vartype role_name: str - :ivar description: The role definition description. - :vartype description: str - :ivar role_type: The role type. - :vartype role_type: str - :ivar permissions: Role definition permissions. - :vartype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :ivar assignable_scopes: Role definition assignable scopes. - :vartype assignable_scopes: list[str] - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "role_name": {"key": "properties.roleName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "role_type": {"key": "properties.type", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[Permission]"}, - "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - } - - def __init__( - self, - *, - role_name: Optional[str] = None, - description: Optional[str] = None, - role_type: Optional[str] = None, - permissions: Optional[List["_models.Permission"]] = None, - assignable_scopes: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_name: The role name. - :paramtype role_name: str - :keyword description: The role definition description. - :paramtype description: str - :keyword role_type: The role type. - :paramtype role_type: str - :keyword permissions: Role definition permissions. - :paramtype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] - :keyword assignable_scopes: Role definition assignable scopes. - :paramtype assignable_scopes: list[str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = role_name - self.description = description - self.role_type = role_type - self.permissions = permissions - self.assignable_scopes = assignable_scopes - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - - -class RoleDefinitionFilter(_serialization.Model): - """Role Definitions filter. - - :ivar role_name: Returns role definition with the specific name. - :vartype role_name: str - :ivar type: Returns role definition with the specific type. - :vartype type: str - """ - - _attribute_map = { - "role_name": {"key": "roleName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword role_name: Returns role definition with the specific name. - :paramtype role_name: str - :keyword type: Returns role definition with the specific type. - :paramtype type: str - """ - super().__init__(**kwargs) - self.role_name = role_name - self.type = type - - -class RoleDefinitionListResult(_serialization.Model): - """Role definition list operation result. - - :ivar value: Role definition list. - :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role definition list. - :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyRule(_serialization.Model): - """The role management policy rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, - RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, - RoleManagementPolicyNotificationRule - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - } - - _subtype_map = { - "rule_type": { - "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", - } - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - """ - super().__init__(**kwargs) - self.id = id - self.rule_type: Optional[str] = None - self.target = target - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy approval rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :ivar setting: The approval setting. - :vartype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "setting": {"key": "setting", "type": "ApprovalSettings"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - setting: Optional["_models.ApprovalSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :keyword setting: The approval setting. - :paramtype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyApprovalRule" - self.setting = setting - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy authentication context rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :ivar is_enabled: The value indicating if rule is enabled. - :vartype is_enabled: bool - :ivar claim_value: The claim value. - :vartype claim_value: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "claim_value": {"key": "claimValue", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_enabled: Optional[bool] = None, - claim_value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :keyword is_enabled: The value indicating if rule is enabled. - :paramtype is_enabled: bool - :keyword claim_value: The claim value. - :paramtype claim_value: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" - self.is_enabled = is_enabled - self.claim_value = claim_value - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy enablement rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :ivar enabled_rules: The list of enabled rules. - :vartype enabled_rules: list[str or - ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "enabled_rules": {"key": "enabledRules", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :keyword enabled_rules: The list of enabled rules. - :paramtype enabled_rules: list[str or - ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyEnablementRule" - self.enabled_rules = enabled_rules - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy expiration rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :ivar is_expiration_required: The value indicating whether expiration is required. - :vartype is_expiration_required: bool - :ivar maximum_duration: The maximum duration of expiration in timespan. - :vartype maximum_duration: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, - "maximum_duration": {"key": "maximumDuration", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_expiration_required: Optional[bool] = None, - maximum_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :keyword is_expiration_required: The value indicating whether expiration is required. - :paramtype is_expiration_required: bool - :keyword maximum_duration: The maximum duration of expiration in timespan. - :paramtype maximum_duration: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyExpirationRule" - self.is_expiration_required = is_expiration_required - self.maximum_duration = maximum_duration - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy notification rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :ivar notification_type: The type of notification. "Email" - :vartype notification_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism - :ivar notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :vartype notification_level: str or - ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel - :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :vartype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType - :ivar notification_recipients: The list of notification recipients. - :vartype notification_recipients: list[str] - :ivar is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :vartype is_default_recipients_enabled: bool - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "notification_type": {"key": "notificationType", "type": "str"}, - "notification_level": {"key": "notificationLevel", "type": "str"}, - "recipient_type": {"key": "recipientType", "type": "str"}, - "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, - "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, - notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, - recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, - notification_recipients: Optional[List[str]] = None, - is_default_recipients_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget - :keyword notification_type: The type of notification. "Email" - :paramtype notification_type: str or - ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism - :keyword notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :paramtype notification_level: str or - ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel - :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :paramtype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType - :keyword notification_recipients: The list of notification recipients. - :paramtype notification_recipients: list[str] - :keyword is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :paramtype is_default_recipients_enabled: bool - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyNotificationRule" - self.notification_type = notification_type - self.notification_level = notification_level - self.recipient_type = recipient_type - self.notification_recipients = notification_recipients - self.is_default_recipients_enabled = is_default_recipients_enabled - - -class RoleManagementPolicyRuleTarget(_serialization.Model): - """The role management policy rule target. - - :ivar caller: The caller of the setting. - :vartype caller: str - :ivar operations: The type of operation. - :vartype operations: list[str] - :ivar level: The assignment level to which rule is applied. - :vartype level: str - :ivar target_objects: The list of target objects. - :vartype target_objects: list[str] - :ivar inheritable_settings: The list of inheritable settings. - :vartype inheritable_settings: list[str] - :ivar enforced_settings: The list of enforced settings. - :vartype enforced_settings: list[str] - """ - - _attribute_map = { - "caller": {"key": "caller", "type": "str"}, - "operations": {"key": "operations", "type": "[str]"}, - "level": {"key": "level", "type": "str"}, - "target_objects": {"key": "targetObjects", "type": "[str]"}, - "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, - "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, - } - - def __init__( - self, - *, - caller: Optional[str] = None, - operations: Optional[List[str]] = None, - level: Optional[str] = None, - target_objects: Optional[List[str]] = None, - inheritable_settings: Optional[List[str]] = None, - enforced_settings: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword caller: The caller of the setting. - :paramtype caller: str - :keyword operations: The type of operation. - :paramtype operations: list[str] - :keyword level: The assignment level to which rule is applied. - :paramtype level: str - :keyword target_objects: The list of target objects. - :paramtype target_objects: list[str] - :keyword inheritable_settings: The list of inheritable settings. - :paramtype inheritable_settings: list[str] - :keyword enforced_settings: The list of enforced settings. - :paramtype enforced_settings: list[str] - """ - super().__init__(**kwargs) - self.caller = caller - self.operations = operations - self.level = level - self.target_objects = target_objects - self.inheritable_settings = inheritable_settings - self.enforced_settings = enforced_settings - - -class UserSet(_serialization.Model): - """The detail of a user. - - :ivar user_type: The type of user. Known values are: "User" and "Group". - :vartype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType - :ivar is_backup: The value indicating whether the user is a backup fallback approver. - :vartype is_backup: bool - :ivar id: The object id of the user. - :vartype id: str - :ivar description: The description of the user. - :vartype description: str - """ - - _attribute_map = { - "user_type": {"key": "userType", "type": "str"}, - "is_backup": {"key": "isBackup", "type": "bool"}, - "id": {"key": "id", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - user_type: Optional[Union[str, "_models.UserType"]] = None, - is_backup: Optional[bool] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_type: The type of user. Known values are: "User" and "Group". - :paramtype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType - :keyword is_backup: The value indicating whether the user is a backup fallback approver. - :paramtype is_backup: bool - :keyword id: The object id of the user. - :paramtype id: str - :keyword description: The description of the user. - :paramtype description: str - """ - super().__init__(**kwargs) - self.user_type = user_type - self.is_backup = is_backup - self.id = id - self.description = description - - -class ValidationResponse(_serialization.Model): - """Validation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_valid: Whether or not validation succeeded. - :vartype is_valid: bool - :ivar error_info: Failed validation result details. - :vartype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo - """ - - _validation = { - "is_valid": {"readonly": True}, - } - - _attribute_map = { - "is_valid": {"key": "isValid", "type": "bool"}, - "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, - } - - def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: - """ - :keyword error_info: Failed validation result details. - :paramtype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo - """ - super().__init__(**kwargs) - self.is_valid = None - self.error_info = error_info - - -class ValidationResponseErrorInfo(_serialization.Model): - """Failed validation result details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code indicating why validation failed. - :vartype code: str - :ivar message: Message indicating why validation failed. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/__init__.py deleted file mode 100644 index 336442a84fe5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._deny_assignments_operations import DenyAssignmentsOperations -from ._provider_operations_metadata_operations import ProviderOperationsMetadataOperations -from ._role_assignments_operations import RoleAssignmentsOperations -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DenyAssignmentsOperations", - "ProviderOperationsMetadataOperations", - "RoleAssignmentsOperations", - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py deleted file mode 100644 index a5f86335ed00..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/operations/_role_definitions_operations.py +++ /dev/null @@ -1,587 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{roleId}") - path_format_arguments = { - "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleDefinitionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01.AuthorizationManagementClient`'s - :attr:`role_definitions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: - """Deletes a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition to delete. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or None or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) - - request = build_delete_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Get role definition by name (GUID). - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: _models.RoleDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - scope: str, - role_definition_id: str, - role_definition: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Required. - :type role_definition: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any - ) -> _models.RoleDefinition: - """Creates or updates a role definition. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param role_definition_id: The ID of the role definition. Required. - :type role_definition_id: str - :param role_definition: The values for the role definition. Is either a RoleDefinition type or - a IO type. Required. - :type role_definition: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(role_definition, (IOBase, bytes)): - _content = role_definition - else: - _json = self._serialize.body(role_definition, "RoleDefinition") - - request = build_create_or_update_request( - scope=scope, - role_definition_id=role_definition_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} - - @distributed_trace - def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: - """Get all role definitions that are applicable at scope and above. - - :param scope: The scope of the role definition. Required. - :type scope: str - :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} - - @distributed_trace - def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: - """Gets a role definition by ID. - - :param role_id: 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. Required. - :type role_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleDefinition or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-04-01")) - cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) - - request = build_get_by_id_request( - role_id=role_id, - api_version=api_version, - template_url=self.get_by_id.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleDefinition", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get_by_id.metadata = {"url": "/{roleId}"} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py deleted file mode 100644 index fc34514cd200..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentScheduleRequestsOperations, RoleEligibilityScheduleRequestsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2022_04_01_preview.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2022_04_01_preview.operations.RoleEligibilityScheduleRequestsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py deleted file mode 100644 index d5cab6d0c942..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json deleted file mode 100644 index a256424cc2ad..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_metadata.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "chosen_version": "2022-04-01-preview", - "total_api_version_list": ["2022-04-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "role_assignment_schedule_requests": "RoleAssignmentScheduleRequestsOperations", - "role_eligibility_schedule_requests": "RoleEligibilityScheduleRequestsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index cf6c398f9abd..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentScheduleRequestsOperations, RoleEligibilityScheduleRequestsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: - azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations - :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: - azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" - ) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-04-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py deleted file mode 100644 index 4682afc08b7d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-04-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/__init__.py deleted file mode 100644 index 8321ef0252af..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilityScheduleRequestsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py deleted file mode 100644 index ca3e5a81d474..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py +++ /dev/null @@ -1,593 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_assignment_schedule_requests_operations import ( - build_cancel_request, - build_create_request, - build_get_request, - build_list_for_scope_request, - build_validate_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleAssignmentScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_create_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace_async - async def get( - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Get the specified role assignment schedule request. - - :param scope: The scope of the role assignment schedule request. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule - request to get. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleAssignmentScheduleRequest"]: - """Gets role assignment schedule requests for a scope. - - :param scope: The scope of the role assignments schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role assignment schedule request. - - :param scope: The scope of the role assignment request to cancel. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - cancel. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } - - @overload - async def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_validate_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py deleted file mode 100644 index 530046bd23c0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py +++ /dev/null @@ -1,593 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._role_eligibility_schedule_requests_operations import ( - build_cancel_request, - build_create_request, - build_get_request, - build_list_for_scope_request, - build_validate_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RoleEligibilityScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01_preview.aio.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_create_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace_async - async def get( - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Get the specified role eligibility schedule request. - - :param scope: The scope of the role eligibility schedule request. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule - request to get. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleEligibilityScheduleRequest"]: - """Gets role eligibility schedule requests for a scope. - - :param scope: The scope of the role eligibility schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role eligibility schedule request. - - :param scope: The scope of the role eligibility request to cancel. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - cancel. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } - - @overload - async def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_validate_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/__init__.py deleted file mode 100644 index dcfd7d49a517..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/__init__.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import CloudErrorBody -from ._models_py3 import ExpandedProperties -from ._models_py3 import ExpandedPropertiesPrincipal -from ._models_py3 import ExpandedPropertiesRoleDefinition -from ._models_py3 import ExpandedPropertiesScope -from ._models_py3 import RoleAssignmentScheduleRequest -from ._models_py3 import RoleAssignmentScheduleRequestFilter -from ._models_py3 import RoleAssignmentScheduleRequestListResult -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo -from ._models_py3 import RoleEligibilityScheduleRequest -from ._models_py3 import RoleEligibilityScheduleRequestFilter -from ._models_py3 import RoleEligibilityScheduleRequestListResult -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration -from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo - -from ._authorization_management_client_enums import PrincipalType -from ._authorization_management_client_enums import RequestType -from ._authorization_management_client_enums import Status -from ._authorization_management_client_enums import Type -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CloudErrorBody", - "ExpandedProperties", - "ExpandedPropertiesPrincipal", - "ExpandedPropertiesRoleDefinition", - "ExpandedPropertiesScope", - "RoleAssignmentScheduleRequest", - "RoleAssignmentScheduleRequestFilter", - "RoleAssignmentScheduleRequestListResult", - "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration", - "RoleAssignmentScheduleRequestPropertiesTicketInfo", - "RoleEligibilityScheduleRequest", - "RoleEligibilityScheduleRequestFilter", - "RoleEligibilityScheduleRequestListResult", - "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration", - "RoleEligibilityScheduleRequestPropertiesTicketInfo", - "PrincipalType", - "RequestType", - "Status", - "Type", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index ee7835ef7e2e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The principal type of the assigned principal ID.""" - - USER = "User" - GROUP = "Group" - SERVICE_PRINCIPAL = "ServicePrincipal" - FOREIGN_GROUP = "ForeignGroup" - DEVICE = "Device" - - -class RequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc.""" - - ADMIN_ASSIGN = "AdminAssign" - ADMIN_REMOVE = "AdminRemove" - ADMIN_UPDATE = "AdminUpdate" - ADMIN_EXTEND = "AdminExtend" - ADMIN_RENEW = "AdminRenew" - SELF_ACTIVATE = "SelfActivate" - SELF_DEACTIVATE = "SelfDeactivate" - SELF_EXTEND = "SelfExtend" - SELF_RENEW = "SelfRenew" - - -class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the role assignment schedule request.""" - - ACCEPTED = "Accepted" - PENDING_EVALUATION = "PendingEvaluation" - GRANTED = "Granted" - DENIED = "Denied" - PENDING_PROVISIONING = "PendingProvisioning" - PROVISIONED = "Provisioned" - PENDING_REVOCATION = "PendingRevocation" - REVOKED = "Revoked" - CANCELED = "Canceled" - FAILED = "Failed" - PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" - PENDING_APPROVAL = "PendingApproval" - FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" - PENDING_ADMIN_DECISION = "PendingAdminDecision" - ADMIN_APPROVED = "AdminApproved" - ADMIN_DENIED = "AdminDenied" - TIMED_OUT = "TimedOut" - PROVISIONING_STARTED = "ProvisioningStarted" - INVALID = "Invalid" - PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" - SCHEDULE_CREATED = "ScheduleCreated" - PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" - - -class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of the role assignment schedule expiration.""" - - AFTER_DURATION = "AfterDuration" - AFTER_DATE_TIME = "AfterDateTime" - NO_EXPIRATION = "NoExpiration" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py deleted file mode 100644 index ae6cb622ab14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_models_py3.py +++ /dev/null @@ -1,941 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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 datetime -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class CloudErrorBody(_serialization.Model): - """An error response from the service. - - :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :vartype code: str - :ivar message: A message describing the error, intended to be suitable for display in a user - interface. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :paramtype code: str - :keyword message: A message describing the error, intended to be suitable for display in a user - interface. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class ExpandedProperties(_serialization.Model): - """Expanded info of resource, role and principal. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesScope - :ivar role_definition: Details of role definition. - :vartype role_definition: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesRoleDefinition - :ivar principal: Details of the principal. - :vartype principal: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesPrincipal - """ - - _attribute_map = { - "scope": {"key": "scope", "type": "ExpandedPropertiesScope"}, - "role_definition": {"key": "roleDefinition", "type": "ExpandedPropertiesRoleDefinition"}, - "principal": {"key": "principal", "type": "ExpandedPropertiesPrincipal"}, - } - - def __init__( - self, - *, - scope: Optional["_models.ExpandedPropertiesScope"] = None, - role_definition: Optional["_models.ExpandedPropertiesRoleDefinition"] = None, - principal: Optional["_models.ExpandedPropertiesPrincipal"] = None, - **kwargs: Any - ) -> None: - """ - :keyword scope: Details of the resource scope. - :paramtype scope: ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesScope - :keyword role_definition: Details of role definition. - :paramtype role_definition: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesRoleDefinition - :keyword principal: Details of the principal. - :paramtype principal: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedPropertiesPrincipal - """ - super().__init__(**kwargs) - self.scope = scope - self.role_definition = role_definition - self.principal = principal - - -class ExpandedPropertiesPrincipal(_serialization.Model): - """Details of the principal. - - :ivar id: Id of the principal. - :vartype id: str - :ivar display_name: Display name of the principal. - :vartype display_name: str - :ivar email: Email id of the principal. - :vartype email: str - :ivar type: Type of the principal. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "email": {"key": "email", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - email: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the principal. - :paramtype id: str - :keyword display_name: Display name of the principal. - :paramtype display_name: str - :keyword email: Email id of the principal. - :paramtype email: str - :keyword type: Type of the principal. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.email = email - self.type = type - - -class ExpandedPropertiesRoleDefinition(_serialization.Model): - """Details of role definition. - - :ivar id: Id of the role definition. - :vartype id: str - :ivar display_name: Display name of the role definition. - :vartype display_name: str - :ivar type: Type of the role definition. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Id of the role definition. - :paramtype id: str - :keyword display_name: Display name of the role definition. - :paramtype display_name: str - :keyword type: Type of the role definition. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class ExpandedPropertiesScope(_serialization.Model): - """Details of the resource scope. - - :ivar id: Scope id of the resource. - :vartype id: str - :ivar display_name: Display name of the resource. - :vartype display_name: str - :ivar type: Type of the resource. - :vartype type: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Scope id of the resource. - :paramtype id: str - :keyword display_name: Display name of the resource. - :paramtype display_name: str - :keyword type: Type of the resource. - :paramtype type: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - - -class RoleAssignmentScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Assignment schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule request ID. - :vartype id: str - :ivar name: The role assignment schedule request name. - :vartype name: str - :ivar type: The role assignment schedule request type. - :vartype type: str - :ivar scope: The role assignment schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2022_04_01_preview.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.RequestType - :ivar status: The status of the role assignment schedule request. Known values are: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Status - :ivar approval_id: The approvalId of the role assignment schedule request. - :vartype approval_id: str - :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role - assignment schedule id being updated. - :vartype target_role_assignment_schedule_id: str - :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :vartype target_role_assignment_schedule_instance_id: str - :ivar schedule_info: Schedule info of the role assignment schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :vartype linked_role_eligibility_schedule_id: str - :ivar justification: Justification for the role assignment. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role assignment. - :vartype ticket_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role assignment schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "target_role_assignment_schedule_id": {"key": "properties.targetRoleAssignmentScheduleId", "type": "str"}, - "target_role_assignment_schedule_instance_id": { - "key": "properties.targetRoleAssignmentScheduleInstanceId", - "type": "str", - }, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfo", - }, - "linked_role_eligibility_schedule_id": {"key": "properties.linkedRoleEligibilityScheduleId", "type": "str"}, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleAssignmentScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - target_role_assignment_schedule_id: Optional[str] = None, - target_role_assignment_schedule_instance_id: Optional[str] = None, - schedule_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, - linked_role_eligibility_schedule_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or - ~azure.mgmt.authorization.v2022_04_01_preview.models.RequestType - :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :paramtype target_role_assignment_schedule_id: str - :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :paramtype target_role_assignment_schedule_instance_id: str - :keyword schedule_info: Schedule info of the role assignment schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :paramtype linked_role_eligibility_schedule_id: str - :keyword justification: Justification for the role assignment. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role assignment. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.target_role_assignment_schedule_id = target_role_assignment_schedule_id - self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id - self.schedule_info = schedule_info - self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleAssignmentScheduleRequestFilter(_serialization.Model): - """Role assignment schedule request filter. - - :ivar principal_id: Returns role assignment requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role assignment requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role assignment requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role assignment requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role assignment requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role assignment requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role assignment requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role assignment requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleAssignmentScheduleRequestListResult(_serialization.Model): - """Role assignment schedule request list operation result. - - :ivar value: Role assignment schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleAssignmentScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleAssignmentScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role assignment schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role assignment schedule. - - :ivar start_date_time: Start DateTime of the role assignment schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role assignment schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role assignment schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role assignment schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role assignment schedule. - - :ivar type: Type of the role assignment schedule expiration. Known values are: "AfterDuration", - "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Type - :ivar end_date_time: End DateTime of the role assignment schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role assignment schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role assignment schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Type - :keyword end_date_time: End DateTime of the role assignment schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role assignment schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleAssignmentScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role assignment. - - :ivar ticket_number: Ticket number for the role assignment. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role assignment. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role assignment. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role assignment. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system - - -class RoleEligibilityScheduleRequest(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role Eligibility schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule request ID. - :vartype id: str - :ivar name: The role eligibility schedule request name. - :vartype name: str - :ivar type: The role eligibility schedule request type. - :vartype type: str - :ivar scope: The role eligibility schedule request scope. - :vartype scope: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar principal_id: The principal ID. - :vartype principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Known values are: - "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2022_04_01_preview.models.PrincipalType - :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :vartype request_type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.RequestType - :ivar status: The status of the role eligibility schedule request. Known values are: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", and "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Status - :ivar approval_id: The approvalId of the role eligibility schedule request. - :vartype approval_id: str - :ivar schedule_info: Schedule info of the role eligibility schedule. - :vartype schedule_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :vartype target_role_eligibility_schedule_id: str - :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id - being updated. - :vartype target_role_eligibility_schedule_instance_id: str - :ivar justification: Justification for the role eligibility. - :vartype justification: str - :ivar ticket_info: Ticket Info of the role eligibility. - :vartype ticket_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :ivar 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'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. - :vartype condition_version: str - :ivar created_on: DateTime when role eligibility schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2022_04_01_preview.models.ExpandedProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "principal_type": {"readonly": True}, - "status": {"readonly": True}, - "approval_id": {"readonly": True}, - "created_on": {"readonly": True}, - "requestor_id": {"readonly": True}, - "expanded_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "principal_type": {"key": "properties.principalType", "type": "str"}, - "request_type": {"key": "properties.requestType", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "approval_id": {"key": "properties.approvalId", "type": "str"}, - "schedule_info": { - "key": "properties.scheduleInfo", - "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfo", - }, - "target_role_eligibility_schedule_id": {"key": "properties.targetRoleEligibilityScheduleId", "type": "str"}, - "target_role_eligibility_schedule_instance_id": { - "key": "properties.targetRoleEligibilityScheduleInstanceId", - "type": "str", - }, - "justification": {"key": "properties.justification", "type": "str"}, - "ticket_info": {"key": "properties.ticketInfo", "type": "RoleEligibilityScheduleRequestPropertiesTicketInfo"}, - "condition": {"key": "properties.condition", "type": "str"}, - "condition_version": {"key": "properties.conditionVersion", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "requestor_id": {"key": "properties.requestorId", "type": "str"}, - "expanded_properties": {"key": "properties.expandedProperties", "type": "ExpandedProperties"}, - } - - def __init__( - self, - *, - role_definition_id: Optional[str] = None, - principal_id: Optional[str] = None, - request_type: Optional[Union[str, "_models.RequestType"]] = None, - schedule_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, - target_role_eligibility_schedule_id: Optional[str] = None, - target_role_eligibility_schedule_instance_id: Optional[str] = None, - justification: Optional[str] = None, - ticket_info: Optional["_models.RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, - condition: Optional[str] = None, - condition_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_definition_id: The role definition ID. - :paramtype role_definition_id: str - :keyword principal_id: The principal ID. - :paramtype principal_id: str - :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Known values are: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", - "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", and "SelfRenew". - :paramtype request_type: str or - ~azure.mgmt.authorization.v2022_04_01_preview.models.RequestType - :keyword schedule_info: Schedule info of the role eligibility schedule. - :paramtype schedule_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :paramtype target_role_eligibility_schedule_id: str - :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance - id being updated. - :paramtype target_role_eligibility_schedule_instance_id: str - :keyword justification: Justification for the role eligibility. - :paramtype justification: str - :keyword ticket_info: Ticket Info of the role eligibility. - :paramtype ticket_info: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :keyword 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'. - :paramtype condition: str - :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. - :paramtype condition_version: str - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = role_definition_id - self.principal_id = principal_id - self.principal_type = None - self.request_type = request_type - self.status = None - self.approval_id = None - self.schedule_info = schedule_info - self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id - self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id - self.justification = justification - self.ticket_info = ticket_info - self.condition = condition - self.condition_version = condition_version - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleEligibilityScheduleRequestFilter(_serialization.Model): - """Role eligibility schedule request filter. - - :ivar principal_id: Returns role eligibility requests of the specific principal. - :vartype principal_id: str - :ivar role_definition_id: Returns role eligibility requests of the specific role definition. - :vartype role_definition_id: str - :ivar requestor_id: Returns role eligibility requests created by specific principal. - :vartype requestor_id: str - :ivar status: Returns role eligibility requests of specific status. - :vartype status: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - role_definition_id: Optional[str] = None, - requestor_id: Optional[str] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Returns role eligibility requests of the specific principal. - :paramtype principal_id: str - :keyword role_definition_id: Returns role eligibility requests of the specific role definition. - :paramtype role_definition_id: str - :keyword requestor_id: Returns role eligibility requests created by specific principal. - :paramtype requestor_id: str - :keyword status: Returns role eligibility requests of specific status. - :paramtype status: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.role_definition_id = role_definition_id - self.requestor_id = requestor_id - self.status = status - - -class RoleEligibilityScheduleRequestListResult(_serialization.Model): - """Role eligibility schedule request list operation result. - - :ivar value: Role eligibility schedule request list. - :vartype value: - list[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleEligibilityScheduleRequest]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RoleEligibilityScheduleRequest"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Role eligibility schedule request list. - :paramtype value: - list[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(_serialization.Model): - """Schedule info of the role eligibility schedule. - - :ivar start_date_time: Start DateTime of the role eligibility schedule. - :vartype start_date_time: ~datetime.datetime - :ivar expiration: Expiration of the role eligibility schedule. - :vartype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, - "expiration": {"key": "expiration", "type": "RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"}, - } - - def __init__( - self, - *, - start_date_time: Optional[datetime.datetime] = None, - expiration: Optional["_models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword start_date_time: Start DateTime of the role eligibility schedule. - :paramtype start_date_time: ~datetime.datetime - :keyword expiration: Expiration of the role eligibility schedule. - :paramtype expiration: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - super().__init__(**kwargs) - self.start_date_time = start_date_time - self.expiration = expiration - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(_serialization.Model): - """Expiration of the role eligibility schedule. - - :ivar type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :vartype type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Type - :ivar end_date_time: End DateTime of the role eligibility schedule. - :vartype end_date_time: ~datetime.datetime - :ivar duration: Duration of the role eligibility schedule in TimeSpan. - :vartype duration: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, - "duration": {"key": "duration", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.Type"]] = None, - end_date_time: Optional[datetime.datetime] = None, - duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of the role eligibility schedule expiration. Known values are: - "AfterDuration", "AfterDateTime", and "NoExpiration". - :paramtype type: str or ~azure.mgmt.authorization.v2022_04_01_preview.models.Type - :keyword end_date_time: End DateTime of the role eligibility schedule. - :paramtype end_date_time: ~datetime.datetime - :keyword duration: Duration of the role eligibility schedule in TimeSpan. - :paramtype duration: str - """ - super().__init__(**kwargs) - self.type = type - self.end_date_time = end_date_time - self.duration = duration - - -class RoleEligibilityScheduleRequestPropertiesTicketInfo(_serialization.Model): - """Ticket Info of the role eligibility. - - :ivar ticket_number: Ticket number for the role eligibility. - :vartype ticket_number: str - :ivar ticket_system: Ticket system name for the role eligibility. - :vartype ticket_system: str - """ - - _attribute_map = { - "ticket_number": {"key": "ticketNumber", "type": "str"}, - "ticket_system": {"key": "ticketSystem", "type": "str"}, - } - - def __init__( - self, *, ticket_number: Optional[str] = None, ticket_system: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword ticket_number: Ticket number for the role eligibility. - :paramtype ticket_number: str - :keyword ticket_system: Ticket system name for the role eligibility. - :paramtype ticket_system: str - """ - super().__init__(**kwargs) - self.ticket_number = ticket_number - self.ticket_system = ticket_system diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/__init__.py deleted file mode 100644 index 8321ef0252af..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations -from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RoleAssignmentScheduleRequestsOperations", - "RoleEligibilityScheduleRequestsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py deleted file mode 100644 index fdb871273b10..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_assignment_schedule_requests_operations.py +++ /dev/null @@ -1,741 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleAssignmentScheduleRequestName": _SERIALIZER.url( - "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleAssignmentScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01_preview.AuthorizationManagementClient`'s - :attr:`role_assignment_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Creates a role assignment schedule request. - - :param 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. Required. - :type scope: str - :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The - name must be unique and different for each role assignment. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_create_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def get( - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Get the specified role assignment schedule request. - - :param scope: The scope of the role assignment schedule request. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule - request to get. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleAssignmentScheduleRequest"]: - """Gets role assignment schedule requests for a scope. - - :param scope: The scope of the role assignments schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role assignment schedule request. - - :param scope: The scope of the role assignment request to cancel. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - cancel. Required. - :type role_assignment_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" - } - - @overload - def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: _models.RoleAssignmentScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate( - self, - scope: str, - role_assignment_schedule_request_name: str, - parameters: Union[_models.RoleAssignmentScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleAssignmentScheduleRequest: - """Validates a new role assignment schedule request. - - :param scope: The scope of the role assignment request to validate. Required. - :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment request to - validate. Required. - :type role_assignment_schedule_request_name: str - :param parameters: Parameters for the role assignment schedule request. Is either a - RoleAssignmentScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleAssignmentScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleAssignmentScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") - - request = build_validate_request( - scope=scope, - role_assignment_schedule_request_name=role_assignment_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py deleted file mode 100644 index c1665930d929..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/operations/_role_eligibility_schedule_requests_operations.py +++ /dev/null @@ -1,741 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate", - ) # pylint: disable=line-too-long - path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), - "roleEligibilityScheduleRequestName": _SERIALIZER.url( - "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoleEligibilityScheduleRequestsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_04_01_preview.AuthorizationManagementClient`'s - :attr:`role_eligibility_schedule_requests` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @overload - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Creates a role eligibility schedule request. - - :param 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. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It - can be any valid GUID. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_create_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def get( - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Get the specified role eligibility schedule request. - - :param scope: The scope of the role eligibility schedule request. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule - request to get. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - request = build_get_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" - } - - @distributed_trace - def list_for_scope( - self, scope: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.RoleEligibilityScheduleRequest"]: - """Gets role eligibility schedule requests for a scope. - - :param scope: The scope of the role eligibility schedule requests. Required. - :type scope: str - :param 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. Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_scope_request( - scope=scope, - filter=filter, - api_version=api_version, - template_url=self.list_for_scope.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} - - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any - ) -> None: - """Cancels a pending role eligibility schedule request. - - :param scope: The scope of the role eligibility request to cancel. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - cancel. Required. - :type role_eligibility_schedule_request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_cancel_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" - } - - @overload - def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: _models.RoleEligibilityScheduleRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate( - self, - scope: str, - role_eligibility_schedule_request_name: str, - parameters: Union[_models.RoleEligibilityScheduleRequest, IO], - **kwargs: Any - ) -> _models.RoleEligibilityScheduleRequest: - """Validates a new role eligibility schedule request. - - :param scope: The scope of the role eligibility request to validate. Required. - :type scope: str - :param role_eligibility_schedule_request_name: The name of the role eligibility request to - validate. Required. - :type role_eligibility_schedule_request_name: str - :param parameters: Parameters for the role eligibility schedule request. Is either a - RoleEligibilityScheduleRequest type or a IO type. Required. - :type parameters: - ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RoleEligibilityScheduleRequest or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2022_04_01_preview.models.RoleEligibilityScheduleRequest - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-04-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") - - request = build_validate_request( - scope=scope, - role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.validate.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - validate.metadata = { - "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_04_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py deleted file mode 100644 index 58368cbfc3bf..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations, RoleDefinitionsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations allow you to manage role - definitions. A role definition describes the set of actions that can be performed on resources. - - :ivar permissions: PermissionsOperations operations - :vartype permissions: - azure.mgmt.authorization.v2022_05_01_preview.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2022_05_01_preview.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py deleted file mode 100644 index 81e24c62142a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json deleted file mode 100644 index a704fb3cd3fa..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2022-05-01-preview", - "total_api_version_list": ["2022-05-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations allow you to manage role definitions. A role definition describes the set of actions that can be performed on resources.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": false, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription. Required.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "permissions": "PermissionsOperations", - "role_definitions": "RoleDefinitionsOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index 2e673e62c793..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations, RoleDefinitionsOperations - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations allow you to manage role - definitions. A role definition describes the set of actions that can be performed on resources. - - :ivar permissions: PermissionsOperations operations - :vartype permissions: - azure.mgmt.authorization.v2022_05_01_preview.aio.operations.PermissionsOperations - :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: - azure.mgmt.authorization.v2022_05_01_preview.aio.operations.RoleDefinitionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs - ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py deleted file mode 100644 index bb2c60526bea..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_configuration.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. - :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-05-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/__init__.py deleted file mode 100644 index 10fe5b64a01c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py deleted file mode 100644 index 6427bc44c427..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py +++ /dev/null @@ -1,254 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/__init__.py deleted file mode 100644 index 8c30802fc8d8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/__init__.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import ApprovalSettings -from ._models_py3 import ApprovalStage -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import Permission -from ._models_py3 import PermissionGetResult -from ._models_py3 import Principal -from ._models_py3 import RoleDefinition -from ._models_py3 import RoleDefinitionFilter -from ._models_py3 import RoleDefinitionListResult -from ._models_py3 import RoleManagementPolicyApprovalRule -from ._models_py3 import RoleManagementPolicyAuthenticationContextRule -from ._models_py3 import RoleManagementPolicyEnablementRule -from ._models_py3 import RoleManagementPolicyExpirationRule -from ._models_py3 import RoleManagementPolicyNotificationRule -from ._models_py3 import RoleManagementPolicyRule -from ._models_py3 import RoleManagementPolicyRuleTarget -from ._models_py3 import UserSet - -from ._authorization_management_client_enums import ApprovalMode -from ._authorization_management_client_enums import EnablementRules -from ._authorization_management_client_enums import NotificationDeliveryMechanism -from ._authorization_management_client_enums import NotificationLevel -from ._authorization_management_client_enums import RecipientType -from ._authorization_management_client_enums import RoleManagementPolicyRuleType -from ._authorization_management_client_enums import UserType -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ApprovalSettings", - "ApprovalStage", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Permission", - "PermissionGetResult", - "Principal", - "RoleDefinition", - "RoleDefinitionFilter", - "RoleDefinitionListResult", - "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule", - "RoleManagementPolicyRule", - "RoleManagementPolicyRuleTarget", - "UserSet", - "ApprovalMode", - "EnablementRules", - "NotificationDeliveryMechanism", - "NotificationLevel", - "RecipientType", - "RoleManagementPolicyRuleType", - "UserType", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index fc526582f560..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class ApprovalMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - SINGLE_STAGE = "SingleStage" - SERIAL = "Serial" - PARALLEL = "Parallel" - NO_APPROVAL = "NoApproval" - - -class EnablementRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of enablement rule.""" - - MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" - JUSTIFICATION = "Justification" - TICKETING = "Ticketing" - - -class NotificationDeliveryMechanism(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of notification.""" - - EMAIL = "Email" - - -class NotificationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The notification level.""" - - NONE = "None" - CRITICAL = "Critical" - ALL = "All" - - -class RecipientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recipient type.""" - - REQUESTOR = "Requestor" - APPROVER = "Approver" - ADMIN = "Admin" - - -class RoleManagementPolicyRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of rule.""" - - ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" - ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" - ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" - ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" - ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" - - -class UserType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of user.""" - - USER = "User" - GROUP = "Group" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py deleted file mode 100644 index dbd980877d8d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_models_py3.py +++ /dev/null @@ -1,1016 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ApprovalSettings(_serialization.Model): - """The approval settings. - - :ivar is_approval_required: Determines whether approval is required or not. - :vartype is_approval_required: bool - :ivar is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :vartype is_approval_required_for_extension: bool - :ivar is_requestor_justification_required: Determine whether requestor justification is - required. - :vartype is_requestor_justification_required: bool - :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", - and "NoApproval". - :vartype approval_mode: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode - :ivar approval_stages: The approval stages of the request. - :vartype approval_stages: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] - """ - - _attribute_map = { - "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, - "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, - "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, - "approval_mode": {"key": "approvalMode", "type": "str"}, - "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, - } - - def __init__( - self, - *, - is_approval_required: Optional[bool] = None, - is_approval_required_for_extension: Optional[bool] = None, - is_requestor_justification_required: Optional[bool] = None, - approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, - approval_stages: Optional[List["_models.ApprovalStage"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_approval_required: Determines whether approval is required or not. - :paramtype is_approval_required: bool - :keyword is_approval_required_for_extension: Determines whether approval is required for - assignment extension. - :paramtype is_approval_required_for_extension: bool - :keyword is_requestor_justification_required: Determine whether requestor justification is - required. - :paramtype is_requestor_justification_required: bool - :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", - "Parallel", and "NoApproval". - :paramtype approval_mode: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode - :keyword approval_stages: The approval stages of the request. - :paramtype approval_stages: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] - """ - super().__init__(**kwargs) - self.is_approval_required = is_approval_required - self.is_approval_required_for_extension = is_approval_required_for_extension - self.is_requestor_justification_required = is_requestor_justification_required - self.approval_mode = approval_mode - self.approval_stages = approval_stages - - -class ApprovalStage(_serialization.Model): - """The approval stage. - - :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :vartype approval_stage_time_out_in_days: int - :ivar is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :vartype is_approver_justification_required: bool - :ivar escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :vartype escalation_time_in_minutes: int - :ivar primary_approvers: The primary approver of the request. - :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] - :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. - :vartype is_escalation_enabled: bool - :ivar escalation_approvers: The escalation approver of the request. - :vartype escalation_approvers: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] - """ - - _attribute_map = { - "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, - "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, - "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, - "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, - "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, - "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, - } - - def __init__( - self, - *, - approval_stage_time_out_in_days: Optional[int] = None, - is_approver_justification_required: Optional[bool] = None, - escalation_time_in_minutes: Optional[int] = None, - primary_approvers: Optional[List["_models.UserSet"]] = None, - is_escalation_enabled: Optional[bool] = None, - escalation_approvers: Optional[List["_models.UserSet"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :paramtype approval_stage_time_out_in_days: int - :keyword is_approver_justification_required: Determines whether approver need to provide - justification for his decision. - :paramtype is_approver_justification_required: bool - :keyword escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approve. - :paramtype escalation_time_in_minutes: int - :keyword primary_approvers: The primary approver of the request. - :paramtype primary_approvers: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] - :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. - :paramtype is_escalation_enabled: bool - :keyword escalation_approvers: The escalation approver of the request. - :paramtype escalation_approvers: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] - """ - super().__init__(**kwargs) - self.approval_stage_time_out_in_days = approval_stage_time_out_in_days - self.is_approver_justification_required = is_approver_justification_required - self.escalation_time_in_minutes = escalation_time_in_minutes - self.primary_approvers = primary_approvers - self.is_escalation_enabled = is_escalation_enabled - self.escalation_approvers = escalation_approvers - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class Permission(_serialization.Model): - """Role definition permissions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar actions: Allowed actions. - :vartype actions: list[str] - :ivar not_actions: Denied actions. - :vartype not_actions: list[str] - :ivar data_actions: Allowed Data actions. - :vartype data_actions: list[str] - :ivar not_data_actions: Denied Data actions. - :vartype not_data_actions: list[str] - :ivar condition: The conditions on the role definition. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :vartype condition: str - :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. - :vartype condition_version: str - """ - - _validation = { - "condition": {"readonly": True}, - "condition_version": {"readonly": True}, - } - - _attribute_map = { - "actions": {"key": "actions", "type": "[str]"}, - "not_actions": {"key": "notActions", "type": "[str]"}, - "data_actions": {"key": "dataActions", "type": "[str]"}, - "not_data_actions": {"key": "notDataActions", "type": "[str]"}, - "condition": {"key": "condition", "type": "str"}, - "condition_version": {"key": "conditionVersion", "type": "str"}, - } - - def __init__( - self, - *, - actions: Optional[List[str]] = None, - not_actions: Optional[List[str]] = None, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword actions: Allowed actions. - :paramtype actions: list[str] - :keyword not_actions: Denied actions. - :paramtype not_actions: list[str] - :keyword data_actions: Allowed Data actions. - :paramtype data_actions: list[str] - :keyword not_data_actions: Denied Data actions. - :paramtype not_data_actions: list[str] - """ - super().__init__(**kwargs) - self.actions = actions - self.not_actions = not_actions - self.data_actions = data_actions - self.not_data_actions = not_data_actions - self.condition = None - self.condition_version = None - - -class PermissionGetResult(_serialization.Model): - """Permissions information. - - :ivar value: An array of permissions. - :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Permission]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: An array of permissions. - :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Principal(_serialization.Model): - """The name of the entity last modified it. - - :ivar id: The id of the principal made changes. - :vartype id: str - :ivar display_name: The name of the principal made changes. - :vartype display_name: str - :ivar type: Type of principal such as user , group etc. - :vartype type: str - :ivar email: Email of principal. - :vartype email: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - display_name: Optional[str] = None, - type: Optional[str] = None, - email: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the principal made changes. - :paramtype id: str - :keyword display_name: The name of the principal made changes. - :paramtype display_name: str - :keyword type: Type of principal such as user , group etc. - :paramtype type: str - :keyword email: Email of principal. - :paramtype email: str - """ - super().__init__(**kwargs) - self.id = id - self.display_name = display_name - self.type = type - self.email = email - - -class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :ivar role_name: The role name. - :vartype role_name: str - :ivar description: The role definition description. - :vartype description: str - :ivar role_type: The role type. - :vartype role_type: str - :ivar permissions: Role definition permissions. - :vartype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :ivar assignable_scopes: Role definition assignable scopes. - :vartype assignable_scopes: list[str] - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "created_on": {"readonly": True}, - "updated_on": {"readonly": True}, - "created_by": {"readonly": True}, - "updated_by": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "role_name": {"key": "properties.roleName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "role_type": {"key": "properties.type", "type": "str"}, - "permissions": {"key": "properties.permissions", "type": "[Permission]"}, - "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, - "created_by": {"key": "properties.createdBy", "type": "str"}, - "updated_by": {"key": "properties.updatedBy", "type": "str"}, - } - - def __init__( - self, - *, - role_name: Optional[str] = None, - description: Optional[str] = None, - role_type: Optional[str] = None, - permissions: Optional[List["_models.Permission"]] = None, - assignable_scopes: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword role_name: The role name. - :paramtype role_name: str - :keyword description: The role definition description. - :paramtype description: str - :keyword role_type: The role type. - :paramtype role_type: str - :keyword permissions: Role definition permissions. - :paramtype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :keyword assignable_scopes: Role definition assignable scopes. - :paramtype assignable_scopes: list[str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = role_name - self.description = description - self.role_type = role_type - self.permissions = permissions - self.assignable_scopes = assignable_scopes - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - - -class RoleDefinitionFilter(_serialization.Model): - """Role Definitions filter. - - :ivar role_name: Returns role definition with the specific name. - :vartype role_name: str - :ivar type: Returns role definition with the specific type. - :vartype type: str - """ - - _attribute_map = { - "role_name": {"key": "roleName", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword role_name: Returns role definition with the specific name. - :paramtype role_name: str - :keyword type: Returns role definition with the specific type. - :paramtype type: str - """ - super().__init__(**kwargs) - self.role_name = role_name - self.type = type - - -class RoleDefinitionListResult(_serialization.Model): - """Role definition list operation result. - - :ivar value: Role definition list. - :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RoleDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Role definition list. - :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class RoleManagementPolicyRule(_serialization.Model): - """The role management policy rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, - RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, - RoleManagementPolicyNotificationRule - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - } - - _subtype_map = { - "rule_type": { - "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", - "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", - "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", - } - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - """ - super().__init__(**kwargs) - self.id = id - self.rule_type: Optional[str] = None - self.target = target - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy approval rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :ivar setting: The approval setting. - :vartype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "setting": {"key": "setting", "type": "ApprovalSettings"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - setting: Optional["_models.ApprovalSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :keyword setting: The approval setting. - :paramtype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyApprovalRule" - self.setting = setting - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy authentication context rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :ivar is_enabled: The value indicating if rule is enabled. - :vartype is_enabled: bool - :ivar claim_value: The claim value. - :vartype claim_value: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "claim_value": {"key": "claimValue", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_enabled: Optional[bool] = None, - claim_value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :keyword is_enabled: The value indicating if rule is enabled. - :paramtype is_enabled: bool - :keyword claim_value: The claim value. - :paramtype claim_value: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" - self.is_enabled = is_enabled - self.claim_value = claim_value - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy enablement rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :ivar enabled_rules: The list of enabled rules. - :vartype enabled_rules: list[str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "enabled_rules": {"key": "enabledRules", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :keyword enabled_rules: The list of enabled rules. - :paramtype enabled_rules: list[str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyEnablementRule" - self.enabled_rules = enabled_rules - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy expiration rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :ivar is_expiration_required: The value indicating whether expiration is required. - :vartype is_expiration_required: bool - :ivar maximum_duration: The maximum duration of expiration in timespan. - :vartype maximum_duration: str - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, - "maximum_duration": {"key": "maximumDuration", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - is_expiration_required: Optional[bool] = None, - maximum_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :keyword is_expiration_required: The value indicating whether expiration is required. - :paramtype is_expiration_required: bool - :keyword maximum_duration: The maximum duration of expiration in timespan. - :paramtype maximum_duration: str - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyExpirationRule" - self.is_expiration_required = is_expiration_required - self.maximum_duration = maximum_duration - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy notification rule. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The id of the rule. - :vartype id: str - :ivar rule_type: The type of rule. Required. Known values are: - "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and - "RoleManagementPolicyNotificationRule". - :vartype rule_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType - :ivar target: The target of the current rule. - :vartype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :ivar notification_type: The type of notification. "Email" - :vartype notification_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism - :ivar notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :vartype notification_level: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel - :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :vartype recipient_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType - :ivar notification_recipients: The list of notification recipients. - :vartype notification_recipients: list[str] - :ivar is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :vartype is_default_recipients_enabled: bool - """ - - _validation = { - "rule_type": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "rule_type": {"key": "ruleType", "type": "str"}, - "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, - "notification_type": {"key": "notificationType", "type": "str"}, - "notification_level": {"key": "notificationLevel", "type": "str"}, - "recipient_type": {"key": "recipientType", "type": "str"}, - "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, - "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, - notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, - notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, - recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, - notification_recipients: Optional[List[str]] = None, - is_default_recipients_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The id of the rule. - :paramtype id: str - :keyword target: The target of the current rule. - :paramtype target: - ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget - :keyword notification_type: The type of notification. "Email" - :paramtype notification_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism - :keyword notification_level: The notification level. Known values are: "None", "Critical", and - "All". - :paramtype notification_level: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel - :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and - "Admin". - :paramtype recipient_type: str or - ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType - :keyword notification_recipients: The list of notification recipients. - :paramtype notification_recipients: list[str] - :keyword is_default_recipients_enabled: Determines if the notification will be sent to the - recipient type specified in the policy rule. - :paramtype is_default_recipients_enabled: bool - """ - super().__init__(id=id, target=target, **kwargs) - self.rule_type: str = "RoleManagementPolicyNotificationRule" - self.notification_type = notification_type - self.notification_level = notification_level - self.recipient_type = recipient_type - self.notification_recipients = notification_recipients - self.is_default_recipients_enabled = is_default_recipients_enabled - - -class RoleManagementPolicyRuleTarget(_serialization.Model): - """The role management policy rule target. - - :ivar caller: The caller of the setting. - :vartype caller: str - :ivar operations: The type of operation. - :vartype operations: list[str] - :ivar level: The assignment level to which rule is applied. - :vartype level: str - :ivar target_objects: The list of target objects. - :vartype target_objects: list[str] - :ivar inheritable_settings: The list of inheritable settings. - :vartype inheritable_settings: list[str] - :ivar enforced_settings: The list of enforced settings. - :vartype enforced_settings: list[str] - """ - - _attribute_map = { - "caller": {"key": "caller", "type": "str"}, - "operations": {"key": "operations", "type": "[str]"}, - "level": {"key": "level", "type": "str"}, - "target_objects": {"key": "targetObjects", "type": "[str]"}, - "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, - "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, - } - - def __init__( - self, - *, - caller: Optional[str] = None, - operations: Optional[List[str]] = None, - level: Optional[str] = None, - target_objects: Optional[List[str]] = None, - inheritable_settings: Optional[List[str]] = None, - enforced_settings: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword caller: The caller of the setting. - :paramtype caller: str - :keyword operations: The type of operation. - :paramtype operations: list[str] - :keyword level: The assignment level to which rule is applied. - :paramtype level: str - :keyword target_objects: The list of target objects. - :paramtype target_objects: list[str] - :keyword inheritable_settings: The list of inheritable settings. - :paramtype inheritable_settings: list[str] - :keyword enforced_settings: The list of enforced settings. - :paramtype enforced_settings: list[str] - """ - super().__init__(**kwargs) - self.caller = caller - self.operations = operations - self.level = level - self.target_objects = target_objects - self.inheritable_settings = inheritable_settings - self.enforced_settings = enforced_settings - - -class UserSet(_serialization.Model): - """The detail of a user. - - :ivar user_type: The type of user. Known values are: "User" and "Group". - :vartype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType - :ivar is_backup: The value indicating whether the user is a backup fallback approver. - :vartype is_backup: bool - :ivar id: The object id of the user. - :vartype id: str - :ivar description: The description of the user. - :vartype description: str - """ - - _attribute_map = { - "user_type": {"key": "userType", "type": "str"}, - "is_backup": {"key": "isBackup", "type": "bool"}, - "id": {"key": "id", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - user_type: Optional[Union[str, "_models.UserType"]] = None, - is_backup: Optional[bool] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_type: The type of user. Known values are: "User" and "Group". - :paramtype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType - :keyword is_backup: The value indicating whether the user is a backup fallback approver. - :paramtype is_backup: bool - :keyword id: The object id of the user. - :paramtype id: str - :keyword description: The description of the user. - :paramtype description: str - """ - super().__init__(**kwargs) - self.user_type = user_type - self.is_backup = is_backup - self.id = id - self.description = description diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/__init__.py deleted file mode 100644 index 10fe5b64a01c..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._permissions_operations import PermissionsOperations -from ._role_definitions_operations import RoleDefinitionsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PermissionsOperations", - "RoleDefinitionsOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py deleted file mode 100644 index bbebc9f28537..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py +++ /dev/null @@ -1,331 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_for_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_request( - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 - ), - "resourceProviderNamespace": _SERIALIZER.url( - "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True - ), - "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), - "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), - "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", pattern=r".+"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PermissionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s - :attr:`permissions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource group. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" - } - - @distributed_trace - def list_for_resource( - self, - resource_group_name: str, - resource_provider_namespace: str, - parent_resource_path: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.Permission"]: - """Gets all permissions the caller has for a resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource provider. Required. - :type resource_provider_namespace: str - :param parent_resource_path: The parent resource identity. Required. - :type parent_resource_path: str - :param resource_type: The resource type of the resource. Required. - :type resource_type: str - :param resource_name: The name of the resource to get the permissions for. Required. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Permission or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") - ) - cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_for_resource_request( - resource_group_name=resource_group_name, - resource_provider_namespace=resource_provider_namespace, - parent_resource_path=parent_resource_path, - resource_type=resource_type, - resource_name=resource_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_for_resource.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PermissionGetResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_for_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" - } diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_05_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/__init__.py deleted file mode 100644 index 019f2f208c14..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py deleted file mode 100644 index b1dfd0af0d72..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_authorization_management_client.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AlertConfigurationsOperations, - AlertDefinitionsOperations, - AlertIncidentsOperations, - AlertOperationOperations, - AlertsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.operations.AlertsOperations - :ivar alert_configurations: AlertConfigurationsOperations operations - :vartype alert_configurations: - azure.mgmt.authorization.v2022_08_01_preview.operations.AlertConfigurationsOperations - :ivar alert_definitions: AlertDefinitionsOperations operations - :vartype alert_definitions: - azure.mgmt.authorization.v2022_08_01_preview.operations.AlertDefinitionsOperations - :ivar alert_incidents: AlertIncidentsOperations operations - :vartype alert_incidents: - azure.mgmt.authorization.v2022_08_01_preview.operations.AlertIncidentsOperations - :ivar alert_operation: AlertOperationOperations operations - :vartype alert_operation: - azure.mgmt.authorization.v2022_08_01_preview.operations.AlertOperationOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_configurations = AlertConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_definitions = AlertDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_incidents = AlertIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_operation = AlertOperationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "AuthorizationManagementClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py deleted file mode 100644 index 033d7e5798b5..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json deleted file mode 100644 index 53b46ccb1488..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_metadata.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "chosen_version": "2022-08-01-preview", - "total_api_version_list": ["2022-08-01-preview"], - "client": { - "name": "AuthorizationManagementClient", - "filename": "_authorization_management_client", - "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential: \"TokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true, - "method_location": "positional" - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure. Required.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version: Optional[str]=None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "alerts": "AlertsOperations", - "alert_configurations": "AlertConfigurationsOperations", - "alert_definitions": "AlertDefinitionsOperations", - "alert_incidents": "AlertIncidentsOperations", - "alert_operation": "AlertOperationOperations" - } -} diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_vendor.py +++ /dev/null @@ -1,30 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -VERSION = "4.0.0" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/__init__.py deleted file mode 100644 index a6e41513a3c6..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._authorization_management_client import AuthorizationManagementClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AuthorizationManagementClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) - -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py deleted file mode 100644 index ea3406cd35a0..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_authorization_management_client.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ( - AlertConfigurationsOperations, - AlertDefinitionsOperations, - AlertIncidentsOperations, - AlertOperationOperations, - AlertsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Role based access control provides you a way to apply granular level policy administration down - to individual resources or resource groups. These operations enable you to manage role - assignments. A role assignment grants access to Azure Active Directory users. - - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertsOperations - :ivar alert_configurations: AlertConfigurationsOperations operations - :vartype alert_configurations: - azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertConfigurationsOperations - :ivar alert_definitions: AlertDefinitionsOperations operations - :vartype alert_definitions: - azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertDefinitionsOperations - :ivar alert_incidents: AlertIncidentsOperations operations - :vartype alert_incidents: - azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertIncidentsOperations - :ivar alert_operation: AlertOperationOperations operations - :vartype alert_operation: - azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertOperationOperations - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". - :type base_url: str - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - """ - - def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any - ) -> None: - self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - self._serialize.client_side_validation = False - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_configurations = AlertConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_definitions = AlertDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_incidents = AlertIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - self.alert_operation = AlertOperationOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client._send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AuthorizationManagementClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py deleted file mode 100644 index 278d20daec1f..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for AuthorizationManagementClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str - """ - - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2022-08-01-preview") - - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index f755caaa9c2a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._alerts_operations import AlertsOperations -from ._alert_configurations_operations import AlertConfigurationsOperations -from ._alert_definitions_operations import AlertDefinitionsOperations -from ._alert_incidents_operations import AlertIncidentsOperations -from ._alert_operation_operations import AlertOperationOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", - "AlertConfigurationsOperations", - "AlertDefinitionsOperations", - "AlertIncidentsOperations", - "AlertOperationOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/__init__.py deleted file mode 100644 index 96b97b97e7c8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/__init__.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._models_py3 import Alert -from ._models_py3 import AlertConfiguration -from ._models_py3 import AlertConfigurationListResult -from ._models_py3 import AlertConfigurationProperties -from ._models_py3 import AlertDefinition -from ._models_py3 import AlertDefinitionListResult -from ._models_py3 import AlertIncident -from ._models_py3 import AlertIncidentListResult -from ._models_py3 import AlertIncidentProperties -from ._models_py3 import AlertListResult -from ._models_py3 import AlertOperationResult -from ._models_py3 import AzureRolesAssignedOutsidePimAlertConfigurationProperties -from ._models_py3 import AzureRolesAssignedOutsidePimAlertIncidentProperties -from ._models_py3 import CloudErrorBody -from ._models_py3 import DuplicateRoleCreatedAlertConfigurationProperties -from ._models_py3 import DuplicateRoleCreatedAlertIncidentProperties -from ._models_py3 import TooManyOwnersAssignedToResourceAlertConfigurationProperties -from ._models_py3 import TooManyOwnersAssignedToResourceAlertIncidentProperties -from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties -from ._models_py3 import TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties - -from ._authorization_management_client_enums import SeverityLevel -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Alert", - "AlertConfiguration", - "AlertConfigurationListResult", - "AlertConfigurationProperties", - "AlertDefinition", - "AlertDefinitionListResult", - "AlertIncident", - "AlertIncidentListResult", - "AlertIncidentProperties", - "AlertListResult", - "AlertOperationResult", - "AzureRolesAssignedOutsidePimAlertConfigurationProperties", - "AzureRolesAssignedOutsidePimAlertIncidentProperties", - "CloudErrorBody", - "DuplicateRoleCreatedAlertConfigurationProperties", - "DuplicateRoleCreatedAlertIncidentProperties", - "TooManyOwnersAssignedToResourceAlertConfigurationProperties", - "TooManyOwnersAssignedToResourceAlertIncidentProperties", - "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", - "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", - "SeverityLevel", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_authorization_management_client_enums.py deleted file mode 100644 index bca84eec8e53..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_authorization_management_client_enums.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class SeverityLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Severity level of the alert.""" - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py deleted file mode 100644 index ba2f22ba8cb7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,987 +0,0 @@ -# coding=utf-8 -# pylint: disable=too-many-lines -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from typing import Any, List, Optional, TYPE_CHECKING - -from ... import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class Alert(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The alert. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The alert ID. - :vartype id: str - :ivar name: The alert name. - :vartype name: str - :ivar type: The alert type. - :vartype type: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_active: False by default; true if the alert is active. - :vartype is_active: bool - :ivar incident_count: The number of generated incidents of the alert. - :vartype incident_count: int - :ivar last_modified_date_time: The date time when the alert configuration was updated or new - incidents were generated. - :vartype last_modified_date_time: ~datetime.datetime - :ivar last_scanned_date_time: The date time when the alert was last scanned. - :vartype last_scanned_date_time: ~datetime.datetime - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - :ivar alert_incidents: The alert incidents. - :vartype alert_incidents: - list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] - :ivar alert_configuration: The alert configuration. - :vartype alert_configuration: - ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "scope": {"readonly": True}, - "incident_count": {"readonly": True}, - "last_modified_date_time": {"readonly": True}, - "last_scanned_date_time": {"readonly": True}, - "alert_definition": {"readonly": True}, - "alert_incidents": {"readonly": True}, - "alert_configuration": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "is_active": {"key": "properties.isActive", "type": "bool"}, - "incident_count": {"key": "properties.incidentCount", "type": "int"}, - "last_modified_date_time": {"key": "properties.lastModifiedDateTime", "type": "iso-8601"}, - "last_scanned_date_time": {"key": "properties.lastScannedDateTime", "type": "iso-8601"}, - "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, - "alert_incidents": {"key": "properties.alertIncidents", "type": "[AlertIncident]"}, - "alert_configuration": {"key": "properties.alertConfiguration", "type": "AlertConfiguration"}, - } - - def __init__(self, *, is_active: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_active: False by default; true if the alert is active. - :paramtype is_active: bool - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.is_active = is_active - self.incident_count = None - self.last_modified_date_time = None - self.last_scanned_date_time = None - self.alert_definition = None - self.alert_incidents = None - self.alert_configuration = None - - -class AlertConfiguration(_serialization.Model): - """Alert configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The alert configuration ID. - :vartype id: str - :ivar name: The alert configuration name. - :vartype name: str - :ivar type: The alert configuration type. - :vartype type: str - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "alert_definition_id": {"key": "properties.alertDefinitionId", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "properties.alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "properties.alertDefinition", "type": "AlertDefinition"}, - } - - def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.alert_definition_id = None - self.scope = None - self.is_enabled = is_enabled - self.alert_configuration_type: Optional[str] = None - self.alert_definition = None - - -class AlertConfigurationListResult(_serialization.Model): - """Alert configuration list operation result. - - :ivar value: Alert configuration list. - :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertConfiguration]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AlertConfiguration"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Alert configuration list. - :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertConfiguration] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AlertConfigurationProperties(_serialization.Model): - """Alert configuration properties. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureRolesAssignedOutsidePimAlertConfigurationProperties, - DuplicateRoleCreatedAlertConfigurationProperties, - TooManyOwnersAssignedToResourceAlertConfigurationProperties, - TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. Required. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - """ - - _validation = { - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_configuration_type": {"required": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, - } - - _subtype_map = { - "alert_configuration_type": { - "AzureRolesAssignedOutsidePimAlertConfiguration": "AzureRolesAssignedOutsidePimAlertConfigurationProperties", - "DuplicateRoleCreatedAlertConfiguration": "DuplicateRoleCreatedAlertConfigurationProperties", - "TooManyOwnersAssignedToResourceAlertConfiguration": "TooManyOwnersAssignedToResourceAlertConfigurationProperties", - "TooManyPermanentOwnersAssignedToResourceAlertConfiguration": "TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties", - } - } - - def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - """ - super().__init__(**kwargs) - self.alert_definition_id = None - self.scope = None - self.is_enabled = is_enabled - self.alert_configuration_type: Optional[str] = None - self.alert_definition = None - - -class AlertDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Alert definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The alert definition ID. - :vartype id: str - :ivar name: The alert definition name. - :vartype name: str - :ivar type: The alert definition type. - :vartype type: str - :ivar display_name: The alert display name. - :vartype display_name: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar description: The alert description. - :vartype description: str - :ivar severity_level: Severity level of the alert. Known values are: "Low", "Medium", and - "High". - :vartype severity_level: str or - ~azure.mgmt.authorization.v2022_08_01_preview.models.SeverityLevel - :ivar security_impact: Security impact of the alert. - :vartype security_impact: str - :ivar mitigation_steps: The methods to mitigate the alert. - :vartype mitigation_steps: str - :ivar how_to_prevent: The ways to prevent the alert. - :vartype how_to_prevent: str - :ivar is_remediatable: True if the alert can be remediated; false, otherwise. - :vartype is_remediatable: bool - :ivar is_configurable: True if the alert configuration can be configured; false, otherwise. - :vartype is_configurable: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"readonly": True}, - "scope": {"readonly": True}, - "description": {"readonly": True}, - "severity_level": {"readonly": True}, - "security_impact": {"readonly": True}, - "mitigation_steps": {"readonly": True}, - "how_to_prevent": {"readonly": True}, - "is_remediatable": {"readonly": True}, - "is_configurable": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "severity_level": {"key": "properties.severityLevel", "type": "str"}, - "security_impact": {"key": "properties.securityImpact", "type": "str"}, - "mitigation_steps": {"key": "properties.mitigationSteps", "type": "str"}, - "how_to_prevent": {"key": "properties.howToPrevent", "type": "str"}, - "is_remediatable": {"key": "properties.isRemediatable", "type": "bool"}, - "is_configurable": {"key": "properties.isConfigurable", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = None - self.scope = None - self.description = None - self.severity_level = None - self.security_impact = None - self.mitigation_steps = None - self.how_to_prevent = None - self.is_remediatable = None - self.is_configurable = None - - -class AlertDefinitionListResult(_serialization.Model): - """Alert definition list operation result. - - :ivar value: Alert definition list. - :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.AlertDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Alert definition list. - :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AlertIncident(_serialization.Model): - """Alert incident. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The alert incident ID. - :vartype id: str - :ivar name: The alert incident name. - :vartype name: str - :ivar type: The alert incident type. - :vartype type: str - :ivar alert_incident_type: The alert incident type. - :vartype alert_incident_type: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "alert_incident_type": {"key": "properties.alertIncidentType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.alert_incident_type: Optional[str] = None - - -class AlertIncidentListResult(_serialization.Model): - """Alert incident list operation result. - - :ivar value: Alert incident list. - :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AlertIncident]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.AlertIncident"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Alert incident list. - :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.AlertIncident] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AlertIncidentProperties(_serialization.Model): - """Alert incident properties. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureRolesAssignedOutsidePimAlertIncidentProperties, - DuplicateRoleCreatedAlertIncidentProperties, - TooManyOwnersAssignedToResourceAlertIncidentProperties, - TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties - - All required parameters must be populated in order to send to Azure. - - :ivar alert_incident_type: The alert incident type. Required. - :vartype alert_incident_type: str - """ - - _validation = { - "alert_incident_type": {"required": True}, - } - - _attribute_map = { - "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, - } - - _subtype_map = { - "alert_incident_type": { - "AzureRolesAssignedOutsidePimAlertIncident": "AzureRolesAssignedOutsidePimAlertIncidentProperties", - "DuplicateRoleCreatedAlertIncident": "DuplicateRoleCreatedAlertIncidentProperties", - "TooManyOwnersAssignedToResourceAlertIncident": "TooManyOwnersAssignedToResourceAlertIncidentProperties", - "TooManyPermanentOwnersAssignedToResourceAlertIncident": "TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_incident_type: Optional[str] = None - - -class AlertListResult(_serialization.Model): - """Alert list operation result. - - :ivar value: Alert list. - :vartype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Alert]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Alert"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Alert list. - :paramtype value: list[~azure.mgmt.authorization.v2022_08_01_preview.models.Alert] - :keyword next_link: The URL to use for getting the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AlertOperationResult(_serialization.Model): - """Alert operation result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The id of the alert operation. - :vartype id: str - :ivar status: The status of the alert operation. - :vartype status: str - :ivar status_detail: The status detail of the alert operation. - :vartype status_detail: str - :ivar created_date_time: The created date of the alert operation. - :vartype created_date_time: ~datetime.datetime - :ivar last_action_date_time: The last action date of the alert operation. - :vartype last_action_date_time: ~datetime.datetime - :ivar resource_location: The location of the alert associated with the operation. - :vartype resource_location: str - """ - - _validation = { - "id": {"readonly": True}, - "status": {"readonly": True}, - "status_detail": {"readonly": True}, - "created_date_time": {"readonly": True}, - "last_action_date_time": {"readonly": True}, - "resource_location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "status_detail": {"key": "statusDetail", "type": "str"}, - "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, - "last_action_date_time": {"key": "lastActionDateTime", "type": "iso-8601"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.status = None - self.status_detail = None - self.created_date_time = None - self.last_action_date_time = None - self.resource_location = None - - -class AzureRolesAssignedOutsidePimAlertConfigurationProperties(AlertConfigurationProperties): - """The Azure roles assigned outside PIM alert configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. Required. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - """ - - _validation = { - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_configuration_type": {"required": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, - } - - def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.alert_configuration_type: str = "AzureRolesAssignedOutsidePimAlertConfiguration" - - -class AzureRolesAssignedOutsidePimAlertIncidentProperties( - AlertIncidentProperties -): # pylint: disable=too-many-instance-attributes - """Azure roles assigned outside PIM alert incident properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_incident_type: The alert incident type. Required. - :vartype alert_incident_type: str - :ivar assignee_display_name: The assignee display name. - :vartype assignee_display_name: str - :ivar assignee_user_principal_name: The assignee user principal name. - :vartype assignee_user_principal_name: str - :ivar assignee_id: The assignee ID. - :vartype assignee_id: str - :ivar role_display_name: The role display name. - :vartype role_display_name: str - :ivar role_template_id: The role template ID. - :vartype role_template_id: str - :ivar role_definition_id: The role definition ID. - :vartype role_definition_id: str - :ivar assignment_activated_date: The date the assignment was activated. - :vartype assignment_activated_date: ~datetime.datetime - :ivar requestor_id: The requestor ID. - :vartype requestor_id: str - :ivar requestor_display_name: The requestor display name. - :vartype requestor_display_name: str - :ivar requestor_user_principal_name: The requestor user principal name. - :vartype requestor_user_principal_name: str - """ - - _validation = { - "alert_incident_type": {"required": True}, - "assignee_display_name": {"readonly": True}, - "assignee_user_principal_name": {"readonly": True}, - "assignee_id": {"readonly": True}, - "role_display_name": {"readonly": True}, - "role_template_id": {"readonly": True}, - "role_definition_id": {"readonly": True}, - "assignment_activated_date": {"readonly": True}, - "requestor_id": {"readonly": True}, - "requestor_display_name": {"readonly": True}, - "requestor_user_principal_name": {"readonly": True}, - } - - _attribute_map = { - "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, - "assignee_display_name": {"key": "assigneeDisplayName", "type": "str"}, - "assignee_user_principal_name": {"key": "assigneeUserPrincipalName", "type": "str"}, - "assignee_id": {"key": "assigneeId", "type": "str"}, - "role_display_name": {"key": "roleDisplayName", "type": "str"}, - "role_template_id": {"key": "roleTemplateId", "type": "str"}, - "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, - "assignment_activated_date": {"key": "assignmentActivatedDate", "type": "iso-8601"}, - "requestor_id": {"key": "requestorId", "type": "str"}, - "requestor_display_name": {"key": "requestorDisplayName", "type": "str"}, - "requestor_user_principal_name": {"key": "requestorUserPrincipalName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_incident_type: str = "AzureRolesAssignedOutsidePimAlertIncident" - self.assignee_display_name = None - self.assignee_user_principal_name = None - self.assignee_id = None - self.role_display_name = None - self.role_template_id = None - self.role_definition_id = None - self.assignment_activated_date = None - self.requestor_id = None - self.requestor_display_name = None - self.requestor_user_principal_name = None - - -class CloudErrorBody(_serialization.Model): - """An error response from the service. - - :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :vartype code: str - :ivar message: A message describing the error, intended to be suitable for display in a user - interface. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :paramtype code: str - :keyword message: A message describing the error, intended to be suitable for display in a user - interface. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class DuplicateRoleCreatedAlertConfigurationProperties(AlertConfigurationProperties): - """The duplicate role created alert configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. Required. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - """ - - _validation = { - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_configuration_type": {"required": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, - } - - def __init__(self, *, is_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.alert_configuration_type: str = "DuplicateRoleCreatedAlertConfiguration" - - -class DuplicateRoleCreatedAlertIncidentProperties(AlertIncidentProperties): - """Duplicate role created alert incident properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_incident_type: The alert incident type. Required. - :vartype alert_incident_type: str - :ivar role_name: The role name. - :vartype role_name: str - :ivar duplicate_roles: The duplicate roles. - :vartype duplicate_roles: str - :ivar reason: The reason for the incident. - :vartype reason: str - """ - - _validation = { - "alert_incident_type": {"required": True}, - "role_name": {"readonly": True}, - "duplicate_roles": {"readonly": True}, - "reason": {"readonly": True}, - } - - _attribute_map = { - "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, - "role_name": {"key": "roleName", "type": "str"}, - "duplicate_roles": {"key": "duplicateRoles", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_incident_type: str = "DuplicateRoleCreatedAlertIncident" - self.role_name = None - self.duplicate_roles = None - self.reason = None - - -class TooManyOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): - """Too many owners assigned to resource alert configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. Required. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - :ivar threshold_number_of_owners: The threshold number of owners. - :vartype threshold_number_of_owners: int - :ivar threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of - owners out of all role members. - :vartype threshold_percentage_of_owners_out_of_all_role_members: int - """ - - _validation = { - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_configuration_type": {"required": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, - "threshold_number_of_owners": {"key": "thresholdNumberOfOwners", "type": "int"}, - "threshold_percentage_of_owners_out_of_all_role_members": { - "key": "thresholdPercentageOfOwnersOutOfAllRoleMembers", - "type": "int", - }, - } - - def __init__( - self, - *, - is_enabled: Optional[bool] = None, - threshold_number_of_owners: Optional[int] = None, - threshold_percentage_of_owners_out_of_all_role_members: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - :keyword threshold_number_of_owners: The threshold number of owners. - :paramtype threshold_number_of_owners: int - :keyword threshold_percentage_of_owners_out_of_all_role_members: The threshold percentage of - owners out of all role members. - :paramtype threshold_percentage_of_owners_out_of_all_role_members: int - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.alert_configuration_type: str = "TooManyOwnersAssignedToResourceAlertConfiguration" - self.threshold_number_of_owners = threshold_number_of_owners - self.threshold_percentage_of_owners_out_of_all_role_members = ( - threshold_percentage_of_owners_out_of_all_role_members - ) - - -class TooManyOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): - """Too many owners assigned to resource alert incident properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_incident_type: The alert incident type. Required. - :vartype alert_incident_type: str - :ivar assignee_name: The assignee name. - :vartype assignee_name: str - :ivar assignee_type: The assignee type. - :vartype assignee_type: str - """ - - _validation = { - "alert_incident_type": {"required": True}, - "assignee_name": {"readonly": True}, - "assignee_type": {"readonly": True}, - } - - _attribute_map = { - "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, - "assignee_name": {"key": "assigneeName", "type": "str"}, - "assignee_type": {"key": "assigneeType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_incident_type: str = "TooManyOwnersAssignedToResourceAlertIncident" - self.assignee_name = None - self.assignee_type = None - - -class TooManyPermanentOwnersAssignedToResourceAlertConfigurationProperties(AlertConfigurationProperties): - """Too many permanent owners assigned to resource alert configuration properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_definition_id: The alert definition ID. - :vartype alert_definition_id: str - :ivar scope: The alert scope. - :vartype scope: str - :ivar is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :vartype is_enabled: bool - :ivar alert_configuration_type: The alert configuration type. Required. - :vartype alert_configuration_type: str - :ivar alert_definition: The alert definition. - :vartype alert_definition: ~azure.mgmt.authorization.v2022_08_01_preview.models.AlertDefinition - :ivar threshold_number_of_permanent_owners: The threshold number of permanent owners. - :vartype threshold_number_of_permanent_owners: int - :ivar threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage of - permanent owners out of all owners. - :vartype threshold_percentage_of_permanent_owners_out_of_all_owners: int - """ - - _validation = { - "alert_definition_id": {"readonly": True}, - "scope": {"readonly": True}, - "alert_configuration_type": {"required": True}, - "alert_definition": {"readonly": True}, - } - - _attribute_map = { - "alert_definition_id": {"key": "alertDefinitionId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - "is_enabled": {"key": "isEnabled", "type": "bool"}, - "alert_configuration_type": {"key": "alertConfigurationType", "type": "str"}, - "alert_definition": {"key": "alertDefinition", "type": "AlertDefinition"}, - "threshold_number_of_permanent_owners": {"key": "thresholdNumberOfPermanentOwners", "type": "int"}, - "threshold_percentage_of_permanent_owners_out_of_all_owners": { - "key": "thresholdPercentageOfPermanentOwnersOutOfAllOwners", - "type": "int", - }, - } - - def __init__( - self, - *, - is_enabled: Optional[bool] = None, - threshold_number_of_permanent_owners: Optional[int] = None, - threshold_percentage_of_permanent_owners_out_of_all_owners: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_enabled: True if the alert is enabled, false will disable the scanning for the - specific alert. - :paramtype is_enabled: bool - :keyword threshold_number_of_permanent_owners: The threshold number of permanent owners. - :paramtype threshold_number_of_permanent_owners: int - :keyword threshold_percentage_of_permanent_owners_out_of_all_owners: The threshold percentage - of permanent owners out of all owners. - :paramtype threshold_percentage_of_permanent_owners_out_of_all_owners: int - """ - super().__init__(is_enabled=is_enabled, **kwargs) - self.alert_configuration_type: str = "TooManyPermanentOwnersAssignedToResourceAlertConfiguration" - self.threshold_number_of_permanent_owners = threshold_number_of_permanent_owners - self.threshold_percentage_of_permanent_owners_out_of_all_owners = ( - threshold_percentage_of_permanent_owners_out_of_all_owners - ) - - -class TooManyPermanentOwnersAssignedToResourceAlertIncidentProperties(AlertIncidentProperties): - """Too many permanent owners assigned to resource alert incident properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar alert_incident_type: The alert incident type. Required. - :vartype alert_incident_type: str - :ivar assignee_name: The assignee name. - :vartype assignee_name: str - :ivar assignee_type: The assignee type. - :vartype assignee_type: str - """ - - _validation = { - "alert_incident_type": {"required": True}, - "assignee_name": {"readonly": True}, - "assignee_type": {"readonly": True}, - } - - _attribute_map = { - "alert_incident_type": {"key": "alertIncidentType", "type": "str"}, - "assignee_name": {"key": "assigneeName", "type": "str"}, - "assignee_type": {"key": "assigneeType", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.alert_incident_type: str = "TooManyPermanentOwnersAssignedToResourceAlertIncident" - self.assignee_name = None - self.assignee_type = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/__init__.py deleted file mode 100644 index f755caaa9c2a..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from ._alerts_operations import AlertsOperations -from ._alert_configurations_operations import AlertConfigurationsOperations -from ._alert_definitions_operations import AlertDefinitionsOperations -from ._alert_incidents_operations import AlertIncidentsOperations -from ._alert_operation_operations import AlertOperationOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "AlertsOperations", - "AlertConfigurationsOperations", - "AlertDefinitionsOperations", - "AlertIncidentsOperations", - "AlertOperationOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2022_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_accept_recommendations.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_accept_recommendations.py new file mode 100644 index 000000000000..b54227fa211f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_accept_recommendations.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python access_review_instance_accept_recommendations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.access_review_instance.accept_recommendations( + schedule_definition_id="488a6d0e-0a63-4946-86e3-1f5bbc934661", + id="d9b9e056-7004-470b-bf21-1635e98487da", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/AccessReviewInstanceAcceptRecommendations.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_apply_decisions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_apply_decisions.py new file mode 100644 index 000000000000..d31d8547ef40 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_apply_decisions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python access_review_instance_apply_decisions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_instance.apply_decisions( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + id="d9b9e056-7004-470b-bf21-1635e98487da", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/AccessReviewInstanceApplyDecisions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_reset_decisions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_reset_decisions.py new file mode 100644 index 000000000000..8d8f9c8bb480 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_reset_decisions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python access_review_instance_reset_decisions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_instance.reset_decisions( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + id="d9b9e056-7004-470b-bf21-1635e98487da", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/AccessReviewInstanceResetDecisions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_send_reminders.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_send_reminders.py new file mode 100644 index 000000000000..cdf9c640a0b1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/access_review_instance_send_reminders.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python access_review_instance_send_reminders.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_instance.send_reminders( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + id="d9b9e056-7004-470b-bf21-1635e98487da", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/AccessReviewInstanceSendReminders.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_assignment_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_assignment_schedule_request_by_name.py new file mode 100644 index 000000000000..37304783e118 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_assignment_schedule_request_by_name.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python cancel_role_assignment_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.role_assignment_schedule_requests.cancel( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_request_name="fea7a502-9a96-4806-a26f-eee560e52045", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_eligibility_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_eligibility_schedule_request_by_name.py new file mode 100644 index 000000000000..a591f8214bb4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/cancel_role_eligibility_schedule_request_by_name.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python cancel_role_eligibility_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.role_eligibility_schedule_requests.cancel( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_request_name="64caffb6-55c0-4deb-a585-68e948ea1ad6", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_history_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_history_definition.py new file mode 100644 index 000000000000..6c3ee63345c0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_history_definition.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python delete_access_review_history_definition.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_history_definition.delete_by_id( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + history_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/DeleteAccessReviewHistoryDefinition.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_schedule_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_schedule_definition.py new file mode 100644 index 000000000000..f05514d61b5d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_access_review_schedule_definition.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python delete_access_review_schedule_definition.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_schedule_definitions.delete_by_id( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/DeleteAccessReviewScheduleDefinition.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py index 6b2656137037..859cbb8065d4 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_definition.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/DeleteRoleDefinition.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/DeleteRoleDefinition.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy.py new file mode 100644 index 000000000000..bc5c666af143 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python delete_role_management_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.role_management_policies.delete( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_name="570c3619-7688-4b34-b290-2b8bb3ccab2a", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/DeleteRoleManagementPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy_assignment.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy_assignment.py new file mode 100644 index 000000000000..d53fc91a941b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/delete_role_management_policy_assignment.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python delete_role_management_policy_assignment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.role_management_policy_assignments.delete( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_assignment_name="b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/DeleteRoleManagementPolicyAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/elevate_access.py similarity index 83% rename from sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py rename to sdk/authorization/azure-mgmt-authorization/generated_samples/elevate_access.py index e46ca94e24e6..c50649260661 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_name.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/elevate_access.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -14,7 +16,7 @@ pip install azure-identity pip install azure-mgmt-authorization # USAGE - python get_role_definition_by_name.py + python elevate_access.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,13 +31,9 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.role_definitions.get( - scope="scope", - role_definition_id="roleDefinitionId", - ) - print(response) + client.global_administrator.elevate_access() -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2015-07-01/examples/ElevateAccess.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_default_settings.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_default_settings.py new file mode 100644 index 000000000000..6583bccbef74 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_default_settings.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_default_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_default_settings.get( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewDefaultSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition.py new file mode 100644 index 000000000000..5f21faa9c7d3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_history_definition.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_history_definitions.get_by_id( + scope="subscriptions/129a304b-4aea-4b86-a9f7-ba7e2b23737a", + history_definition_id="44724910-d7a5-4c29-b28f-db73e717165a", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewHistoryDefinition.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition_instances.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition_instances.py new file mode 100644 index 000000000000..31e852b3cc49 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definition_instances.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_history_definition_instances.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_history_definition_instances.list( + scope="subscriptions/129a304b-4aea-4b86-a9f7-ba7e2b23737a", + history_definition_id="44724910-d7a5-4c29-b28f-db73e717165a", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewHistoryDefinitionInstances.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definitions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definitions.py new file mode 100644 index 000000000000..ba1e70c9a91b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_history_definitions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_history_definitions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_history_definitions.list( + scope="subscriptions/129a304b-4aea-4b86-a9f7-ba7e2b23737a", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewHistoryDefinitions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance.py new file mode 100644 index 000000000000..9db77135b773 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_instances.get_by_id( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + id="4135f961-be78-4005-8101-c72a5af307a2", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_assigned_for_my_approval.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_assigned_for_my_approval.py new file mode 100644 index 000000000000..1678533c30f0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_assigned_for_my_approval.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance_assigned_for_my_approval.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.access_review_instances_assigned_for_my_approval.get_by_id( + schedule_definition_id="488a6d0e-0a63-4946-86e3-1f5bbc934661", + id="4135f961-be78-4005-8101-c72a5af307a2", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstanceAssignedForMyApproval.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_contacted_reviewers.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_contacted_reviewers.py new file mode 100644 index 000000000000..f6e07f66be76 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_contacted_reviewers.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance_contacted_reviewers.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_instance_contacted_reviewers.list( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="265785a7-a81f-4201-8a18-bb0db95982b7", + id="f25ed880-9c31-4101-bc57-825d8df3b58c", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstanceContactedReviewers.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_decisions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_decisions.py new file mode 100644 index 000000000000..72e646a400a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_decisions.py @@ -0,0 +1,45 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance_decisions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_instance_decisions.list( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="265785a7-a81f-4201-8a18-bb0db95982b7", + id="f25ed880-9c31-4101-bc57-825d8df3b58c", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstanceDecisions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decision_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decision_by_id.py new file mode 100644 index 000000000000..998560ac3b76 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decision_by_id.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance_my_decision_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.access_review_instance_my_decisions.get_by_id( + schedule_definition_id="488a6d0e-0a63-4946-86e3-1f5bbc934661", + id="4135f961-be78-4005-8101-c72a5af307a2", + decision_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstanceMyDecisionById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decisions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decisions.py new file mode 100644 index 000000000000..66668ab7e698 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instance_my_decisions.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instance_my_decisions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.access_review_instance_my_decisions.list( + schedule_definition_id="488a6d0e-0a63-4946-86e3-1f5bbc934661", + id="4135f961-be78-4005-8101-c72a5af307a2", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstanceMyDecisions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances.py new file mode 100644 index 000000000000..4496795db864 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instances.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_instances.list( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="265785a7-a81f-4201-8a18-bb0db95982b7", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstances.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances_assigned_for_my_approval.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances_assigned_for_my_approval.py new file mode 100644 index 000000000000..377bc7215550 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_instances_assigned_for_my_approval.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_instances_assigned_for_my_approval.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.access_review_instances_assigned_for_my_approval.list( + schedule_definition_id="488a6d0e-0a63-4946-86e3-1f5bbc934661", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewInstancesAssignedForMyApproval.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definition.py new file mode 100644 index 000000000000..dcf0d1e6d531 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definition.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_schedule_definition.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_schedule_definitions.get_by_id( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewScheduleDefinition.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions.py new file mode 100644 index 000000000000..bd11c78243a0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_schedule_definitions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_schedule_definitions.list( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewScheduleDefinitions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions_assigned_for_my_approval.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions_assigned_for_my_approval.py new file mode 100644 index 000000000000..de0a6d36105b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_access_review_schedule_definitions_assigned_for_my_approval.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_access_review_schedule_definitions_assigned_for_my_approval.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.access_review_schedule_definitions_assigned_for_my_approval.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/GetAccessReviewScheduleDefinitionsAssignedForMyApproval.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_by_id.py new file mode 100644 index 000000000000..cfb603e11b2e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_by_id.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alerts.get( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyOwnersAssignedToResource", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configuration_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configuration_by_id.py new file mode 100644 index 000000000000..271b22e4a01d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configuration_by_id.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_configuration_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_configurations.get( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyOwnersAssignedToResource", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertConfigurationById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configurations.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configurations.py new file mode 100644 index 000000000000..04d5a9e78532 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_configurations.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_configurations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_configurations.list_for_scope( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertConfigurations.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definition_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definition_by_id.py new file mode 100644 index 000000000000..3827f9987cc6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definition_by_id.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_definition_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_definitions.get( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_definition_id="TooManyPermanentOwnersAssignedToResource", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertDefinitionById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definitions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definitions.py new file mode 100644 index 000000000000..d86623e8b6a1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_definitions.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_definitions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_definitions.list_for_scope( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertDefinitions.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incident_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incident_by_id.py new file mode 100644 index 000000000000..6ee33cee7339 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incident_by_id.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_incident_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_incidents.get( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyOwnersAssignedToResource", + alert_incident_id="5cf9ee65-d22e-4784-8b17-3de1c3b7bdcc", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertIncidentById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incidents.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incidents.py new file mode 100644 index 000000000000..f0a838982d6f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_incidents.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_incidents.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_incidents.list_for_scope( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyOwnersAssignedToResource", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertIncidents.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_operation_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_operation_by_id.py new file mode 100644 index 000000000000..23b27aef6402 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alert_operation_by_id.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alert_operation_by_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alert_operation.get( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + operation_id="{operationId}", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlertOperationById.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alerts.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alerts.py new file mode 100644 index 000000000000..6ca37ab731e3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_alerts.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_alerts.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alerts.list_for_scope( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/GetAlerts.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py index 7cf4c74f39aa..6380b8081c84 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_deny_assignments.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py index 8c832da5bdf7..a3492f5ee479 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_all_provider_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_classic_administrators.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_classic_administrators.py new file mode 100644 index 000000000000..90e5e54771fd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_classic_administrators.py @@ -0,0 +1,41 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_classic_administrators.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subId", + ) + + response = client.classic_administrators.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2015-07-01/examples/GetClassicAdministrators.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py index 8bf0ac555760..1f67dbbbe115 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py index 0406575e2e6a..ee5f8d8bda3c 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_name_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py index 39d6ac8f0b11..772fd6b559b6 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignment_by_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py index 473ed4991a81..656b894de50d 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py index 1250e4947513..3ad1c83cb21a 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_deny_assignments_for_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_eligible_child_resources_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_eligible_child_resources_by_scope.py new file mode 100644 index 000000000000..97dbcb557d32 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_eligible_child_resources_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_eligible_child_resources_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.eligible_child_resources.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetEligibleChildResourcesByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py index 0b9782cadbff..99b50b3c0f71 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_permissions.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetPermissions.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/GetPermissions.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py index 7099bb62050d..b927ef8c4618 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_provider_operations_rp.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py index 4e4cb20f687e..90b2717316d3 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_resource_permissions.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -40,6 +42,6 @@ def main(): print(item) -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetResourcePermissions.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/GetResourcePermissions.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_by_name.py new file mode 100644 index 000000000000..c9e1c8d5c986 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedule_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedules.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_name="c9e264ff-3133-4776-a81a-ebc7c33c8ec6", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentScheduleByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instance_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instance_by_name.py new file mode 100644 index 000000000000..162c80f79552 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instance_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedule_instance_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_instances.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_instance_name="ed9b8180-cef7-4c77-a63c-b8566ecfc412", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instances_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instances_by_scope.py new file mode 100644 index 000000000000..3694be2e2b65 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_instances_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedule_instances_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_instances.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_name.py new file mode 100644 index 000000000000..33bfeccfe5d0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_requests.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_request_name="fea7a502-9a96-4806-a26f-eee560e52045", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_scope.py new file mode 100644 index 000000000000..03dab9b55e7a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedule_request_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedule_request_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_requests.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedules_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedules_by_scope.py new file mode 100644 index 000000000000..94e5f8f164aa --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_assignment_schedules_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_assignment_schedules_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedules.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleAssignmentSchedulesByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py index 31d5ddb37f83..930aa45d5551 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_at_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionAtScope.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/GetRoleDefinitionAtScope.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py index 344bd2f600e6..462c3cb0c583 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ @@ -29,12 +31,13 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.role_definitions.get_by_id( - role_id="roleDefinitionId", + response = client.role_definitions.get( + scope="scope", + role_definition_id="roleDefinitionId", ) print(response) -# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionById.json +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/GetRoleDefinitionById.json if __name__ == "__main__": main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_role_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_role_id.py new file mode 100644 index 000000000000..8e746ef9c749 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_definition_by_role_id.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_definition_by_role_id.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_definitions.get_by_id( + role_id="roleDefinitionId", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-05-01-preview/examples/GetRoleDefinitionByRoleId.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_by_name.py new file mode 100644 index 000000000000..4e0231aa5dc7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedule_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedules.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_name="b1477448-2cc6-4ceb-93b4-54a202a89413", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilityScheduleByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instance_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instance_by_name.py new file mode 100644 index 000000000000..984ccf570d6c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instance_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedule_instance_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_instances.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_instance_name="21e4b59a-0499-4fe0-a3c3-43a3055b773a", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instances_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instances_by_scope.py new file mode 100644 index 000000000000..db82b5441f4b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_instances_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedule_instances_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_instances.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_name.py new file mode 100644 index 000000000000..1d2c4332f810 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_requests.get( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_request_name="64caffb6-55c0-4deb-a585-68e948ea1ad6", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_scope.py new file mode 100644 index 000000000000..1258f496cb04 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedule_request_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedule_request_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_requests.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedules_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedules_by_scope.py new file mode 100644 index 000000000000..fe4b862baccc --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_eligibility_schedules_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_eligibility_schedules_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedules.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleEligibilitySchedulesByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_name.py new file mode 100644 index 000000000000..ab2fdbddaa68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_management_policy_assignment_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policy_assignments.get( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_assignment_name="b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_scope.py new file mode 100644 index 000000000000..d552979aa03e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_assignment_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_management_policy_assignment_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policy_assignments.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_name.py new file mode 100644 index 000000000000..7fb89784a212 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_name.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_management_policy_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policies.get( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_name="570c3619-7688-4b34-b290-2b8bb3ccab2a", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleManagementPolicyByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_scope.py new file mode 100644 index 000000000000..513883ea1e14 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/get_role_management_policy_by_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python get_role_management_policy_by_scope.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policies.list_for_scope( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/GetRoleManagementPolicyByScope.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_partial_role_management_policy.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_partial_role_management_policy.py new file mode 100644 index 000000000000..c219d6fd63f3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_partial_role_management_policy.py @@ -0,0 +1,81 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python patch_partial_role_management_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policies.update( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_name="570c3619-7688-4b34-b290-2b8bb3ccab2a", + parameters={ + "properties": { + "rules": [ + { + "exceptionMembers": None, + "id": "Expiration_Admin_Eligibility", + "isExpirationRequired": False, + "maximumDuration": "P180D", + "ruleType": "RoleManagementPolicyExpirationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Admin_Admin_Eligibility", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["admin_admin_eligible@test.com"], + "notificationType": "Email", + "recipientType": "Admin", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + ] + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PatchPartialRoleManagementPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy.py new file mode 100644 index 000000000000..269d264c100b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy.py @@ -0,0 +1,362 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python patch_role_management_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policies.update( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_name="570c3619-7688-4b34-b290-2b8bb3ccab2a", + parameters={ + "properties": { + "rules": [ + { + "exceptionMembers": None, + "id": "Expiration_Admin_Eligibility", + "isExpirationRequired": False, + "maximumDuration": "P180D", + "ruleType": "RoleManagementPolicyExpirationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Admin_Admin_Eligibility", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["admin_admin_eligible@test.com"], + "notificationType": "Email", + "recipientType": "Admin", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Requestor_Admin_Eligibility", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["requestor_admin_eligible@test.com"], + "notificationType": "Email", + "recipientType": "Requestor", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Approver_Admin_Eligibility", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["approver_admin_eligible@test.com"], + "notificationType": "Email", + "recipientType": "Approver", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "enabledRules": [], + "id": "Enablement_Admin_Eligibility", + "ruleType": "RoleManagementPolicyEnablementRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Eligibility", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "exceptionMembers": None, + "id": "Expiration_Admin_Assignment", + "isExpirationRequired": False, + "maximumDuration": "P90D", + "ruleType": "RoleManagementPolicyExpirationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "enabledRules": ["Justification", "MultiFactorAuthentication"], + "id": "Enablement_Admin_Assignment", + "ruleType": "RoleManagementPolicyEnablementRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Admin_Admin_Assignment", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["admin_admin_member@test.com"], + "notificationType": "Email", + "recipientType": "Admin", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Requestor_Admin_Assignment", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["requestor_admin_member@test.com"], + "notificationType": "Email", + "recipientType": "Requestor", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Approver_Admin_Assignment", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["approver_admin_member@test.com"], + "notificationType": "Email", + "recipientType": "Approver", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "Admin", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "exceptionMembers": None, + "id": "Expiration_EndUser_Assignment", + "isExpirationRequired": True, + "maximumDuration": "PT7H", + "ruleType": "RoleManagementPolicyExpirationRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "enabledRules": ["Justification", "MultiFactorAuthentication", "Ticketing"], + "id": "Enablement_EndUser_Assignment", + "ruleType": "RoleManagementPolicyEnablementRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Approval_EndUser_Assignment", + "ruleType": "RoleManagementPolicyApprovalRule", + "setting": { + "approvalMode": "SingleStage", + "approvalStages": [ + { + "approvalStageTimeOutInDays": 1, + "escalationApprovers": None, + "escalationTimeInMinutes": 0, + "isApproverJustificationRequired": True, + "isEscalationEnabled": False, + "primaryApprovers": [ + { + "description": "amansw_new_group", + "id": "2385b0f3-5fa9-43cf-8ca4-b01dc97298cd", + "isBackup": False, + "userType": "Group", + }, + { + "description": "amansw_group", + "id": "2f4913c9-d15b-406a-9946-1d66a28f2690", + "isBackup": False, + "userType": "Group", + }, + ], + } + ], + "isApprovalRequired": True, + "isApprovalRequiredForExtension": False, + "isRequestorJustificationRequired": True, + }, + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "claimValue": "", + "id": "AuthenticationContext_EndUser_Assignment", + "isEnabled": False, + "ruleType": "RoleManagementPolicyAuthenticationContextRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Admin_EndUser_Assignment", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["admin_enduser_member@test.com"], + "notificationType": "Email", + "recipientType": "Admin", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Requestor_EndUser_Assignment", + "isDefaultRecipientsEnabled": False, + "notificationLevel": "Critical", + "notificationRecipients": ["requestor_enduser_member@test.com"], + "notificationType": "Email", + "recipientType": "Requestor", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "Notification_Approver_EndUser_Assignment", + "isDefaultRecipientsEnabled": True, + "notificationLevel": "Critical", + "notificationRecipients": None, + "notificationType": "Email", + "recipientType": "Approver", + "ruleType": "RoleManagementPolicyNotificationRule", + "target": { + "caller": "EndUser", + "enforcedSettings": None, + "inheritableSettings": None, + "level": "Assignment", + "operations": ["All"], + "targetObjects": None, + }, + }, + { + "id": "PIMOnlyMode_Admin_Assignment", + "pimOnlyModeSettings": { + "excludedAssignmentTypes": ["ServicePrincipalsAsTarget"], + "excludes": [ + {"id": "ec42a424-a0c0-4418-8788-d19bdeb03704", "type": "User"}, + {"id": "00029dfb-0218-4e7a-9a85-c15dc0c880bc", "type": "Group"}, + {"id": "0000103d-1fc2-4ac8-81de-71517765655c", "type": "ServicePrincipal"}, + ], + "mode": "Enabled", + }, + "ruleType": "RoleManagementPolicyPimOnlyModeRule", + "target": { + "caller": "Admin", + "enforcedSettings": ["all"], + "inheritableSettings": ["all"], + "level": "Assignment", + "operations": ["all"], + "targetObjects": [], + }, + }, + ] + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PatchRoleManagementPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy_to_enable_pim_only_mode.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy_to_enable_pim_only_mode.py new file mode 100644 index 000000000000..468e0ec7b694 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/patch_role_management_policy_to_enable_pim_only_mode.py @@ -0,0 +1,70 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python patch_role_management_policy_to_enable_pim_only_mode.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policies.update( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_name="570c3619-7688-4b34-b290-2b8bb3ccab2a", + parameters={ + "properties": { + "rules": [ + { + "id": "PIMOnlyMode_Admin_Assignment", + "pimOnlyModeSettings": { + "excludedAssignmentTypes": ["ServicePrincipalsAsTarget"], + "excludes": [ + {"id": "ec42a424-a0c0-4418-8788-d19bdeb03704", "type": "User"}, + {"id": "00029dfb-0218-4e7a-9a85-c15dc0c880bc", "type": "Group"}, + {"id": "0000103d-1fc2-4ac8-81de-71517765655c", "type": "ServicePrincipal"}, + ], + "mode": "Enabled", + }, + "ruleType": "RoleManagementPolicyPimOnlyModeRule", + "target": { + "caller": "Admin", + "enforcedSettings": ["all"], + "inheritableSettings": ["all"], + "level": "Assignment", + "operations": ["all"], + "targetObjects": [], + }, + } + ] + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PatchRoleManagementPolicyToEnablePIMOnlyMode.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/post_access_review_history_definition_instance.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/post_access_review_history_definition_instance.py new file mode 100644 index 000000000000..30fcd989770d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/post_access_review_history_definition_instance.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python post_access_review_history_definition_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.scope_access_review_history_definition_instance.generate_download_uri( + scope="subscriptions/129a304b-4aea-4b86-a9f7-ba7e2b23737a", + history_definition_id="44724910-d7a5-4c29-b28f-db73e717165a", + instance_id="9038f4f3-3d8d-43c3-8ede-669ea082c43b", + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/PostAccessReviewHistoryDefinitionInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_assignment_schedule_request.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_assignment_schedule_request.py new file mode 100644 index 000000000000..ed90958387ed --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_assignment_schedule_request.py @@ -0,0 +1,57 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python put_role_assignment_schedule_request.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_requests.create( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_request_name="fea7a502-9a96-4806-a26f-eee560e52045", + parameters={ + "properties": { + "condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + "conditionVersion": "1.0", + "linkedRoleEligibilityScheduleId": "b1477448-2cc6-4ceb-93b4-54a202a89413", + "principalId": "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + "requestType": "SelfActivate", + "roleDefinitionId": "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + "scheduleInfo": { + "expiration": {"duration": "PT8H", "endDateTime": None, "type": "AfterDuration"}, + "startDateTime": "2020-09-09T21:35:27.91Z", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PutRoleAssignmentScheduleRequest.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_eligibility_schedule_request.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_eligibility_schedule_request.py new file mode 100644 index 000000000000..3b8d7feb822b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_eligibility_schedule_request.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python put_role_eligibility_schedule_request.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_requests.create( + scope="providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_request_name="64caffb6-55c0-4deb-a585-68e948ea1ad6", + parameters={ + "properties": { + "condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + "conditionVersion": "1.0", + "principalId": "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + "requestType": "AdminAssign", + "roleDefinitionId": "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + "scheduleInfo": { + "expiration": {"duration": "P365D", "endDateTime": None, "type": "AfterDuration"}, + "startDateTime": "2020-09-09T21:31:27.91Z", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PutRoleEligibilityScheduleRequest.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_management_policy_assignment.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_management_policy_assignment.py new file mode 100644 index 000000000000..4f47bd90d4ab --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/put_role_management_policy_assignment.py @@ -0,0 +1,50 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python put_role_management_policy_assignment.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_management_policy_assignments.create( + scope="providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + role_management_policy_assignment_name="b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + parameters={ + "properties": { + "policyId": "/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9", + "roleDefinitionId": "/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + "scope": "/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/PutRoleManagementPolicyAssignment.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_alert.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_alert.py new file mode 100644 index 000000000000..7e70e335251e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_alert.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python refresh_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alerts.begin_refresh( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="AzureRolesAssignedOutsidePimAlert", + ).result() + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/RefreshAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_all_alerts.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_all_alerts.py new file mode 100644 index 000000000000..a850b46954da --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/refresh_all_alerts.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python refresh_all_alerts.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.alerts.begin_refresh_all( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + ).result() + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/RefreshAllAlerts.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/remediate_alert_incident.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/remediate_alert_incident.py new file mode 100644 index 000000000000..89738b775578 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/remediate_alert_incident.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python remediate_alert_incident.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.alert_incidents.remediate( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="DuplicateRoleCreated", + alert_incident_id="0645231d-16ba-4ebf-851a-0875df4052bd", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/RemediateAlertIncident.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py index 79724354e685..c6eda5d74a88 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_by_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py index b571ac6a53ad..20f0e2fbefec 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py index 0bf104c5c3f6..5966e55db7b7 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py index 0349481e954e..e97d63e3786a 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_create_for_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py index 3065d4fd2aa6..a06529cea51d 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py index f1d6ec361703..c2a7115e4400 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_delete_by_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py index 95346f257c47..5c84e9ad6a68 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py index e7520e7b690a..f3275d5d978f 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_get_by_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py index 10593e632922..0780649d5768 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py index 03de94e5fed0..dbe079df537d 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_resource_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py index afca98926b25..2146445e371d 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py index b83a8d4ffe33..2a7d66deac6b 100644 --- a/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/role_assignments_list_for_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.authorization import AuthorizationManagementClient """ diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_instance.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_instance.py new file mode 100644 index 000000000000..22ff25c5dbba --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_instance.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python stop_access_review_instance.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_instance.stop( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + id="d9b9e056-7004-470b-bf21-1635e98487da", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/StopAccessReviewInstance.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_schedule_definition.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_schedule_definition.py new file mode 100644 index 000000000000..1235bea299cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/stop_access_review_schedule_definition.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python stop_access_review_schedule_definition.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.scope_access_review_schedule_definitions.stop( + scope="subscriptions/fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + schedule_definition_id="fa73e90b-5bf1-45fd-a182-35ce5fc0674d", + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/StopAccessReviewScheduleDefinition.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/tenant_level_get_access_review_instance_contacted_reviewers.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/tenant_level_get_access_review_instance_contacted_reviewers.py new file mode 100644 index 000000000000..0983374129ef --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/tenant_level_get_access_review_instance_contacted_reviewers.py @@ -0,0 +1,44 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python tenant_level_get_access_review_instance_contacted_reviewers.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.tenant_level_access_review_instance_contacted_reviewers.list( + schedule_definition_id="265785a7-a81f-4201-8a18-bb0db95982b7", + id="f25ed880-9c31-4101-bc57-825d8df3b58c", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2021-12-01-preview/examples/TenantLevelGetAccessReviewInstanceContactedReviewers.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert.py new file mode 100644 index 000000000000..64042c196b5c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python update_alert.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.alerts.update( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyPermanentOwnersAssignedToResource", + parameters={"properties": {"isActive": False}}, + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/UpdateAlert.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert_configuration.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert_configuration.py new file mode 100644 index 000000000000..b37283d205bd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/update_alert_configuration.py @@ -0,0 +1,49 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python update_alert_configuration.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.alert_configurations.update( + scope="subscriptions/afa2a084-766f-4003-8ae1-c4aeb893a99f", + alert_id="TooManyOwnersAssignedToResource", + parameters={ + "properties": { + "alertConfigurationType": "TooManyOwnersAssignedToResourceAlertConfiguration", + "isEnabled": True, + "thresholdNumberOfOwners": 2, + } + }, + ) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/UpdateAlertConfiguration.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_assignment_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_assignment_schedule_request_by_name.py new file mode 100644 index 000000000000..13c9f27ce7f9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_assignment_schedule_request_by_name.py @@ -0,0 +1,57 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python validate_role_assignment_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_assignment_schedule_requests.validate( + scope="subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_assignment_schedule_request_name="fea7a502-9a96-4806-a26f-eee560e52045", + parameters={ + "properties": { + "condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + "conditionVersion": "1.0", + "linkedRoleEligibilityScheduleId": "b1477448-2cc6-4ceb-93b4-54a202a89413", + "principalId": "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + "requestType": "SelfActivate", + "roleDefinitionId": "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + "scheduleInfo": { + "expiration": {"duration": "PT8H", "endDateTime": None, "type": "AfterDuration"}, + "startDateTime": "2020-09-09T21:35:27.91Z", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/ValidateRoleAssignmentScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_eligibility_schedule_request_by_name.py b/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_eligibility_schedule_request_by_name.py new file mode 100644 index 000000000000..1b3f048899a6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_samples/validate_role_eligibility_schedule_request_by_name.py @@ -0,0 +1,56 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.authorization import AuthorizationManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-authorization +# USAGE + python validate_role_eligibility_schedule_request_by_name.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AuthorizationManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.role_eligibility_schedule_requests.validate( + scope="subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", + role_eligibility_schedule_request_name="64caffb6-55c0-4deb-a585-68e948ea1ad6", + parameters={ + "properties": { + "condition": "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + "conditionVersion": "1.0", + "principalId": "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + "requestType": "AdminAssign", + "roleDefinitionId": "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + "scheduleInfo": { + "expiration": {"duration": "P365D", "endDateTime": None, "type": "AfterDuration"}, + "startDateTime": "2020-09-09T21:31:27.91Z", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2024-09-01-preview/examples/ValidateRoleEligibilityScheduleRequestByName.json +if __name__ == "__main__": + main() diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py new file mode 100644 index 000000000000..f8dde025df99 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/conftest.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + authorizationmanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + authorizationmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + authorizationmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + authorizationmanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=authorizationmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=authorizationmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=authorizationmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=authorizationmanagement_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations.py new file mode 100644 index 000000000000..5d651cb67a47 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewDefaultSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_default_settings_get(self, resource_group): + response = self.client.access_review_default_settings.get( + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_default_settings_put(self, resource_group): + response = self.client.access_review_default_settings.put( + properties={ + "autoApplyDecisionsEnabled": bool, + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "endDate": "2020-02-20 00:00:00", + "instanceDurationInDays": 0, + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "startDate": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations_async.py new file mode 100644 index 000000000000..013067ac4111 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_default_settings_operations_async.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewDefaultSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_default_settings_get(self, resource_group): + response = await self.client.access_review_default_settings.get( + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_default_settings_put(self, resource_group): + response = await self.client.access_review_default_settings.put( + properties={ + "autoApplyDecisionsEnabled": bool, + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "endDate": "2020-02-20 00:00:00", + "instanceDurationInDays": 0, + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "startDate": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..be2b0856833d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionInstanceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definition_instance_generate_download_uri(self, resource_group): + response = self.client.access_review_history_definition_instance.generate_download_uri( + history_definition_id="str", + instance_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations_async.py new file mode 100644 index 000000000000..e008fa2f7959 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instance_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionInstanceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definition_instance_generate_download_uri(self, resource_group): + response = await self.client.access_review_history_definition_instance.generate_download_uri( + history_definition_id="str", + instance_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..859371c5aa4d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definition_instances_list(self, resource_group): + response = self.client.access_review_history_definition_instances.list( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations_async.py new file mode 100644 index 000000000000..d181a033c5bc --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_instances_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definition_instances_list(self, resource_group): + response = self.client.access_review_history_definition_instances.list( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations.py new file mode 100644 index 000000000000..3fca7411b112 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definition_create(self, resource_group): + response = self.client.access_review_history_definition.create( + history_definition_id="str", + properties={ + "createdDateTime": "2020-02-20 00:00:00", + "decisions": ["str"], + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "instances": [ + { + "displayName": "str", + "downloadUri": "str", + "expiration": "2020-02-20 00:00:00", + "fulfilledDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "runDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "scopes": [ + { + "assignmentState": "str", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "principalType": "str", + "resourceId": "str", + "roleDefinitionId": "str", + } + ], + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definition_delete_by_id(self, resource_group): + response = self.client.access_review_history_definition.delete_by_id( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations_async.py new file mode 100644 index 000000000000..980351671055 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definition_operations_async.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definition_create(self, resource_group): + response = await self.client.access_review_history_definition.create( + history_definition_id="str", + properties={ + "createdDateTime": "2020-02-20 00:00:00", + "decisions": ["str"], + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "instances": [ + { + "displayName": "str", + "downloadUri": "str", + "expiration": "2020-02-20 00:00:00", + "fulfilledDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "runDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "scopes": [ + { + "assignmentState": "str", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "principalType": "str", + "resourceId": "str", + "roleDefinitionId": "str", + } + ], + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definition_delete_by_id(self, resource_group): + response = await self.client.access_review_history_definition.delete_by_id( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..eaaf4a533fd7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definitions_list(self, resource_group): + response = self.client.access_review_history_definitions.list( + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_history_definitions_get_by_id(self, resource_group): + response = self.client.access_review_history_definitions.get_by_id( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations_async.py new file mode 100644 index 000000000000..65d01829dd9e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_history_definitions_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewHistoryDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definitions_list(self, resource_group): + response = self.client.access_review_history_definitions.list( + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_history_definitions_get_by_id(self, resource_group): + response = await self.client.access_review_history_definitions.get_by_id( + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..1348df6e0407 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceContactedReviewersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.access_review_instance_contacted_reviewers.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations_async.py new file mode 100644 index 000000000000..1223350b3da0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_contacted_reviewers_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceContactedReviewersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.access_review_instance_contacted_reviewers.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..33b21680b024 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceDecisionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_decisions_list(self, resource_group): + response = self.client.access_review_instance_decisions.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations_async.py new file mode 100644 index 000000000000..440ed531d446 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_decisions_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceDecisionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_decisions_list(self, resource_group): + response = self.client.access_review_instance_decisions.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations.py new file mode 100644 index 000000000000..22d02ae545b1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceMyDecisionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_my_decisions_list(self, resource_group): + response = self.client.access_review_instance_my_decisions.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_my_decisions_get_by_id(self, resource_group): + response = self.client.access_review_instance_my_decisions.get_by_id( + schedule_definition_id="str", + id="str", + decision_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_my_decisions_patch(self, resource_group): + response = self.client.access_review_instance_my_decisions.patch( + schedule_definition_id="str", + id="str", + decision_id="str", + properties={ + "appliedDateTime": "2020-02-20 00:00:00", + "applyResult": "str", + "decision": "str", + "displayName": "str", + "id": "str", + "insights": [{"id": "str", "insightCreatedDateTime": {}, "name": "str", "type": "str"}], + "justification": "str", + "membershipTypes": ["str"], + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendation": "str", + "reviewedDateTime": "2020-02-20 00:00:00", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations_async.py new file mode 100644 index 000000000000..965377184d7c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_my_decisions_operations_async.py @@ -0,0 +1,75 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceMyDecisionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_my_decisions_list(self, resource_group): + response = self.client.access_review_instance_my_decisions.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_my_decisions_get_by_id(self, resource_group): + response = await self.client.access_review_instance_my_decisions.get_by_id( + schedule_definition_id="str", + id="str", + decision_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_my_decisions_patch(self, resource_group): + response = await self.client.access_review_instance_my_decisions.patch( + schedule_definition_id="str", + id="str", + decision_id="str", + properties={ + "appliedDateTime": "2020-02-20 00:00:00", + "applyResult": "str", + "decision": "str", + "displayName": "str", + "id": "str", + "insights": [{"id": "str", "insightCreatedDateTime": {}, "name": "str", "type": "str"}], + "justification": "str", + "membershipTypes": ["str"], + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendation": "str", + "reviewedDateTime": "2020-02-20 00:00:00", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations.py new file mode 100644 index 000000000000..94f0e448779c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_stop(self, resource_group): + response = self.client.access_review_instance.stop( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_reset_decisions(self, resource_group): + response = self.client.access_review_instance.reset_decisions( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_apply_decisions(self, resource_group): + response = self.client.access_review_instance.apply_decisions( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_send_reminders(self, resource_group): + response = self.client.access_review_instance.send_reminders( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instance_accept_recommendations(self, resource_group): + response = self.client.access_review_instance.accept_recommendations( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations_async.py new file mode 100644 index 000000000000..3431b7280c35 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instance_operations_async.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstanceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_stop(self, resource_group): + response = await self.client.access_review_instance.stop( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_reset_decisions(self, resource_group): + response = await self.client.access_review_instance.reset_decisions( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_apply_decisions(self, resource_group): + response = await self.client.access_review_instance.apply_decisions( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_send_reminders(self, resource_group): + response = await self.client.access_review_instance.send_reminders( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instance_accept_recommendations(self, resource_group): + response = await self.client.access_review_instance.accept_recommendations( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..9e66c9ed55ce --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstancesAssignedForMyApprovalOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instances_assigned_for_my_approval_list(self, resource_group): + response = self.client.access_review_instances_assigned_for_my_approval.list( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instances_assigned_for_my_approval_get_by_id(self, resource_group): + response = self.client.access_review_instances_assigned_for_my_approval.get_by_id( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations_async.py new file mode 100644 index 000000000000..962941019695 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_assigned_for_my_approval_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstancesAssignedForMyApprovalOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instances_assigned_for_my_approval_list(self, resource_group): + response = self.client.access_review_instances_assigned_for_my_approval.list( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instances_assigned_for_my_approval_get_by_id(self, resource_group): + response = await self.client.access_review_instances_assigned_for_my_approval.get_by_id( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations.py new file mode 100644 index 000000000000..326dc5afb0ce --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instances_list(self, resource_group): + response = self.client.access_review_instances.list( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instances_get_by_id(self, resource_group): + response = self.client.access_review_instances.get_by_id( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_instances_create(self, resource_group): + response = self.client.access_review_instances.create( + schedule_definition_id="str", + id="str", + properties={ + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations_async.py new file mode 100644 index 000000000000..c176cca8d340 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_instances_operations_async.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instances_list(self, resource_group): + response = self.client.access_review_instances.list( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instances_get_by_id(self, resource_group): + response = await self.client.access_review_instances.get_by_id( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_instances_create(self, resource_group): + response = await self.client.access_review_instances.create( + schedule_definition_id="str", + id="str", + properties={ + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..cbfa1064a7c5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_assigned_for_my_approval_list(self, resource_group): + response = self.client.access_review_schedule_definitions_assigned_for_my_approval.list( + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations_async.py new file mode 100644 index 000000000000..e2e50f1b382b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_assigned_for_my_approval_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewScheduleDefinitionsAssignedForMyApprovalOperationsAsync( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_assigned_for_my_approval_list(self, resource_group): + response = self.client.access_review_schedule_definitions_assigned_for_my_approval.list( + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..a9b2714be7e4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewScheduleDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_list(self, resource_group): + response = self.client.access_review_schedule_definitions.list( + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_get_by_id(self, resource_group): + response = self.client.access_review_schedule_definitions.get_by_id( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_delete_by_id(self, resource_group): + response = self.client.access_review_schedule_definitions.delete_by_id( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_create_or_update_by_id(self, resource_group): + response = self.client.access_review_schedule_definitions.create_or_update_by_id( + schedule_definition_id="str", + properties={ + "assignmentState": "str", + "autoApplyDecisionsEnabled": bool, + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "descriptionForAdmins": "str", + "descriptionForReviewers": "str", + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "instanceDurationInDays": 0, + "instances": [ + { + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "resourceId": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "roleDefinitionId": "str", + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_access_review_schedule_definitions_stop(self, resource_group): + response = self.client.access_review_schedule_definitions.stop( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations_async.py new file mode 100644 index 000000000000..c8bc2ba35b9b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_access_review_schedule_definitions_operations_async.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAccessReviewScheduleDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_list(self, resource_group): + response = self.client.access_review_schedule_definitions.list( + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_get_by_id(self, resource_group): + response = await self.client.access_review_schedule_definitions.get_by_id( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_delete_by_id(self, resource_group): + response = await self.client.access_review_schedule_definitions.delete_by_id( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_create_or_update_by_id(self, resource_group): + response = await self.client.access_review_schedule_definitions.create_or_update_by_id( + schedule_definition_id="str", + properties={ + "assignmentState": "str", + "autoApplyDecisionsEnabled": bool, + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "descriptionForAdmins": "str", + "descriptionForReviewers": "str", + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "instanceDurationInDays": 0, + "instances": [ + { + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "resourceId": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "roleDefinitionId": "str", + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_access_review_schedule_definitions_stop(self, resource_group): + response = await self.client.access_review_schedule_definitions.stop( + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations.py new file mode 100644 index 000000000000..3651054ddf22 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_configurations_get(self, resource_group): + response = self.client.alert_configurations.get( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_configurations_update(self, resource_group): + response = self.client.alert_configurations.update( + scope="str", + alert_id="str", + parameters={ + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertDefinitionId": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "scope": "str", + "type": "str", + }, + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_configurations_list_for_scope(self, resource_group): + response = self.client.alert_configurations.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations_async.py new file mode 100644 index 000000000000..24b42957d302 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_configurations_operations_async.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_configurations_get(self, resource_group): + response = await self.client.alert_configurations.get( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_configurations_update(self, resource_group): + response = await self.client.alert_configurations.update( + scope="str", + alert_id="str", + parameters={ + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertDefinitionId": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "scope": "str", + "type": "str", + }, + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_configurations_list_for_scope(self, resource_group): + response = self.client.alert_configurations.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations.py new file mode 100644 index 000000000000..b81ab5577fbb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_definitions_get(self, resource_group): + response = self.client.alert_definitions.get( + scope="str", + alert_definition_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_definitions_list_for_scope(self, resource_group): + response = self.client.alert_definitions.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations_async.py new file mode 100644 index 000000000000..45404e658622 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_definitions_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_definitions_get(self, resource_group): + response = await self.client.alert_definitions.get( + scope="str", + alert_definition_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_definitions_list_for_scope(self, resource_group): + response = self.client.alert_definitions.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations.py new file mode 100644 index 000000000000..a4c1b02d692a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertIncidentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_incidents_get(self, resource_group): + response = self.client.alert_incidents.get( + scope="str", + alert_id="str", + alert_incident_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_incidents_list_for_scope(self, resource_group): + response = self.client.alert_incidents.list_for_scope( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_incidents_remediate(self, resource_group): + response = self.client.alert_incidents.remediate( + scope="str", + alert_id="str", + alert_incident_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations_async.py new file mode 100644 index 000000000000..32cdb6f92c1a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_incidents_operations_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertIncidentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_incidents_get(self, resource_group): + response = await self.client.alert_incidents.get( + scope="str", + alert_id="str", + alert_incident_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_incidents_list_for_scope(self, resource_group): + response = self.client.alert_incidents.list_for_scope( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_incidents_remediate(self, resource_group): + response = await self.client.alert_incidents.remediate( + scope="str", + alert_id="str", + alert_incident_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations.py new file mode 100644 index 000000000000..724e837df2ee --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertOperationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alert_operation_get(self, resource_group): + response = self.client.alert_operation.get( + scope="str", + operation_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations_async.py new file mode 100644 index 000000000000..9656e1ff150f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alert_operation_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertOperationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alert_operation_get(self, resource_group): + response = await self.client.alert_operation.get( + scope="str", + operation_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations.py new file mode 100644 index 000000000000..553ad1a50e47 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations.py @@ -0,0 +1,124 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_get(self, resource_group): + response = self.client.alerts.get( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_update(self, resource_group): + response = self.client.alerts.update( + scope="str", + alert_id="str", + parameters={ + "alertConfiguration": { + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertDefinitionId": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "scope": "str", + "type": "str", + }, + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertIncidents": [{"id": "str", "name": "str", "type": "str"}], + "id": "str", + "incidentCount": 0, + "isActive": bool, + "lastModifiedDateTime": "2020-02-20 00:00:00", + "lastScannedDateTime": "2020-02-20 00:00:00", + "name": "str", + "scope": "str", + "type": "str", + }, + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_list_for_scope(self, resource_group): + response = self.client.alerts.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_begin_refresh(self, resource_group): + response = self.client.alerts.begin_refresh( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_alerts_begin_refresh_all(self, resource_group): + response = self.client.alerts.begin_refresh_all( + scope="str", + api_version="2022-08-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations_async.py new file mode 100644 index 000000000000..6fb67569a326 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_alerts_operations_async.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementAlertsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_get(self, resource_group): + response = await self.client.alerts.get( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_update(self, resource_group): + response = await self.client.alerts.update( + scope="str", + alert_id="str", + parameters={ + "alertConfiguration": { + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertDefinitionId": "str", + "id": "str", + "isEnabled": bool, + "name": "str", + "scope": "str", + "type": "str", + }, + "alertDefinition": { + "description": "str", + "displayName": "str", + "howToPrevent": "str", + "id": "str", + "isConfigurable": bool, + "isRemediatable": bool, + "mitigationSteps": "str", + "name": "str", + "scope": "str", + "securityImpact": "str", + "severityLevel": "str", + "type": "str", + }, + "alertIncidents": [{"id": "str", "name": "str", "type": "str"}], + "id": "str", + "incidentCount": 0, + "isActive": bool, + "lastModifiedDateTime": "2020-02-20 00:00:00", + "lastScannedDateTime": "2020-02-20 00:00:00", + "name": "str", + "scope": "str", + "type": "str", + }, + api_version="2022-08-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_list_for_scope(self, resource_group): + response = self.client.alerts.list_for_scope( + scope="str", + api_version="2022-08-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_begin_refresh(self, resource_group): + response = await ( + await self.client.alerts.begin_refresh( + scope="str", + alert_id="str", + api_version="2022-08-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_alerts_begin_refresh_all(self, resource_group): + response = await ( + await self.client.alerts.begin_refresh_all( + scope="str", + api_version="2022-08-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations.py new file mode 100644 index 000000000000..ac9ab492707f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementClassicAdministratorsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_classic_administrators_list(self, resource_group): + response = self.client.classic_administrators.list( + api_version="2015-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations_async.py new file mode 100644 index 000000000000..6a3932eac769 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_classic_administrators_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementClassicAdministratorsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_classic_administrators_list(self, resource_group): + response = self.client.classic_administrators.list( + api_version="2015-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py new file mode 100644 index 000000000000..438cb9e377cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementDenyAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_list_for_resource(self, resource_group): + response = self.client.deny_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_list_for_resource_group(self, resource_group): + response = self.client.deny_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_list(self, resource_group): + response = self.client.deny_assignments.list( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_get(self, resource_group): + response = self.client.deny_assignments.get( + scope="str", + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_get_by_id(self, resource_group): + response = self.client.deny_assignments.get_by_id( + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_deny_assignments_list_for_scope(self, resource_group): + response = self.client.deny_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py new file mode 100644 index 000000000000..342afc00038a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_deny_assignments_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementDenyAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_list_for_resource(self, resource_group): + response = self.client.deny_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_list_for_resource_group(self, resource_group): + response = self.client.deny_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_list(self, resource_group): + response = self.client.deny_assignments.list( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_get(self, resource_group): + response = await self.client.deny_assignments.get( + scope="str", + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_get_by_id(self, resource_group): + response = await self.client.deny_assignments.get_by_id( + deny_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_deny_assignments_list_for_scope(self, resource_group): + response = self.client.deny_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations.py new file mode 100644 index 000000000000..e1feb810cb6c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementEligibleChildResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_eligible_child_resources_get(self, resource_group): + response = self.client.eligible_child_resources.get( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations_async.py new file mode 100644 index 000000000000..26aa0d841ea0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_eligible_child_resources_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementEligibleChildResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_eligible_child_resources_get(self, resource_group): + response = self.client.eligible_child_resources.get( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations.py new file mode 100644 index 000000000000..6f72924ef23a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementGlobalAdministratorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_global_administrator_elevate_access(self, resource_group): + response = self.client.global_administrator.elevate_access( + api_version="2015-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations_async.py new file mode 100644 index 000000000000..d04b58592cd4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_global_administrator_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementGlobalAdministratorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_global_administrator_elevate_access(self, resource_group): + response = await self.client.global_administrator.elevate_access( + api_version="2015-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations.py new file mode 100644 index 000000000000..f0927dd1f28c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations_async.py new file mode 100644 index 000000000000..24f23b1efd85 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py new file mode 100644 index 000000000000..d32ced8f73ee --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementPermissionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_permissions_list_for_resource_group(self, resource_group): + response = self.client.permissions.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_permissions_list_for_resource(self, resource_group): + response = self.client.permissions.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py new file mode 100644 index 000000000000..dbe7633b13f0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_permissions_operations_async.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementPermissionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_permissions_list_for_resource_group(self, resource_group): + response = self.client.permissions.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_permissions_list_for_resource(self, resource_group): + response = self.client.permissions.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + parent_resource_path="str", + resource_type="str", + resource_name="str", + api_version="2022-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py new file mode 100644 index 000000000000..b5304ccf6b3d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementProviderOperationsMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_provider_operations_metadata_get(self, resource_group): + response = self.client.provider_operations_metadata.get( + resource_provider_namespace="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_provider_operations_metadata_list(self, resource_group): + response = self.client.provider_operations_metadata.list( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py new file mode 100644 index 000000000000..ca1066e14d82 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_provider_operations_metadata_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementProviderOperationsMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_provider_operations_metadata_get(self, resource_group): + response = await self.client.provider_operations_metadata.get( + resource_provider_namespace="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_provider_operations_metadata_list(self, resource_group): + response = self.client.provider_operations_metadata.list( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations.py new file mode 100644 index 000000000000..4bee7ab930c7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentScheduleInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_instances_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedule_instances.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_instances_get(self, resource_group): + response = self.client.role_assignment_schedule_instances.get( + scope="str", + role_assignment_schedule_instance_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations_async.py new file mode 100644 index 000000000000..c822528eed72 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_instances_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentScheduleInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_instances_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedule_instances.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_instances_get(self, resource_group): + response = await self.client.role_assignment_schedule_instances.get( + scope="str", + role_assignment_schedule_instance_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations.py new file mode 100644 index 000000000000..cc7ad9bd9184 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentScheduleRequestsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_requests_create(self, resource_group): + response = self.client.role_assignment_schedule_requests.create( + scope="str", + role_assignment_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "linkedRoleEligibilityScheduleId": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleAssignmentScheduleId": "str", + "targetRoleAssignmentScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_requests_get(self, resource_group): + response = self.client.role_assignment_schedule_requests.get( + scope="str", + role_assignment_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_requests_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedule_requests.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_requests_cancel(self, resource_group): + response = self.client.role_assignment_schedule_requests.cancel( + scope="str", + role_assignment_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedule_requests_validate(self, resource_group): + response = self.client.role_assignment_schedule_requests.validate( + scope="str", + role_assignment_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "linkedRoleEligibilityScheduleId": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleAssignmentScheduleId": "str", + "targetRoleAssignmentScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations_async.py new file mode 100644 index 000000000000..e7e235a5fa53 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedule_requests_operations_async.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentScheduleRequestsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_requests_create(self, resource_group): + response = await self.client.role_assignment_schedule_requests.create( + scope="str", + role_assignment_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "linkedRoleEligibilityScheduleId": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleAssignmentScheduleId": "str", + "targetRoleAssignmentScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_requests_get(self, resource_group): + response = await self.client.role_assignment_schedule_requests.get( + scope="str", + role_assignment_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_requests_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedule_requests.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_requests_cancel(self, resource_group): + response = await self.client.role_assignment_schedule_requests.cancel( + scope="str", + role_assignment_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedule_requests_validate(self, resource_group): + response = await self.client.role_assignment_schedule_requests.validate( + scope="str", + role_assignment_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "linkedRoleEligibilityScheduleId": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleAssignmentScheduleId": "str", + "targetRoleAssignmentScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations.py new file mode 100644 index 000000000000..c934309bebe3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentSchedulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedules_get(self, resource_group): + response = self.client.role_assignment_schedules.get( + scope="str", + role_assignment_schedule_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignment_schedules_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedules.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations_async.py new file mode 100644 index 000000000000..faf427e71a63 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignment_schedules_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentSchedulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedules_get(self, resource_group): + response = await self.client.role_assignment_schedules.get( + scope="str", + role_assignment_schedule_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignment_schedules_list_for_scope(self, resource_group): + response = self.client.role_assignment_schedules.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py new file mode 100644 index 000000000000..3c19126f0d61 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations.py @@ -0,0 +1,162 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_list_for_subscription(self, resource_group): + response = self.client.role_assignments.list_for_subscription( + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_list_for_resource_group(self, resource_group): + response = self.client.role_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_list_for_resource(self, resource_group): + response = self.client.role_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_get(self, resource_group): + response = self.client.role_assignments.get( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_create(self, resource_group): + response = self.client.role_assignments.create( + scope="str", + role_assignment_name="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "str", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_delete(self, resource_group): + response = self.client.role_assignments.delete( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_list_for_scope(self, resource_group): + response = self.client.role_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_get_by_id(self, resource_group): + response = self.client.role_assignments.get_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_create_by_id(self, resource_group): + response = self.client.role_assignments.create_by_id( + role_assignment_id="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "str", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_assignments_delete_by_id(self, resource_group): + response = self.client.role_assignments.delete_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py new file mode 100644 index 000000000000..e25946b2c836 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_assignments_operations_async.py @@ -0,0 +1,163 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_list_for_subscription(self, resource_group): + response = self.client.role_assignments.list_for_subscription( + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_list_for_resource_group(self, resource_group): + response = self.client.role_assignments.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_list_for_resource(self, resource_group): + response = self.client.role_assignments.list_for_resource( + resource_group_name=resource_group.name, + resource_provider_namespace="str", + resource_type="str", + resource_name="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_get(self, resource_group): + response = await self.client.role_assignments.get( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_create(self, resource_group): + response = await self.client.role_assignments.create( + scope="str", + role_assignment_name="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "str", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_delete(self, resource_group): + response = await self.client.role_assignments.delete( + scope="str", + role_assignment_name="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_list_for_scope(self, resource_group): + response = self.client.role_assignments.list_for_scope( + scope="str", + api_version="2022-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_get_by_id(self, resource_group): + response = await self.client.role_assignments.get_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_create_by_id(self, resource_group): + response = await self.client.role_assignments.create_by_id( + role_assignment_id="str", + parameters={ + "principalId": "str", + "roleDefinitionId": "str", + "condition": "str", + "conditionVersion": "str", + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "delegatedManagedIdentityResourceId": "str", + "description": "str", + "principalType": "str", + "scope": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_assignments_delete_by_id(self, resource_group): + response = await self.client.role_assignments.delete_by_id( + role_assignment_id="str", + api_version="2022-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py new file mode 100644 index 000000000000..bf2230e208a9 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_definitions_delete(self, resource_group): + response = self.client.role_definitions.delete( + scope="str", + role_definition_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_definitions_get(self, resource_group): + response = self.client.role_definitions.get( + scope="str", + role_definition_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_definitions_create_or_update(self, resource_group): + response = self.client.role_definitions.create_or_update( + scope="str", + role_definition_id="str", + role_definition={ + "assignableScopes": ["str"], + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "permissions": [ + { + "actions": ["str"], + "condition": "str", + "conditionVersion": "str", + "dataActions": ["str"], + "notActions": ["str"], + "notDataActions": ["str"], + } + ], + "roleName": "str", + "type": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_definitions_list(self, resource_group): + response = self.client.role_definitions.list( + scope="str", + api_version="2022-05-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_definitions_get_by_id(self, resource_group): + response = self.client.role_definitions.get_by_id( + role_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py new file mode 100644 index 000000000000..a6c010d7d29c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_definitions_operations_async.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_definitions_delete(self, resource_group): + response = await self.client.role_definitions.delete( + scope="str", + role_definition_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_definitions_get(self, resource_group): + response = await self.client.role_definitions.get( + scope="str", + role_definition_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_definitions_create_or_update(self, resource_group): + response = await self.client.role_definitions.create_or_update( + scope="str", + role_definition_id="str", + role_definition={ + "assignableScopes": ["str"], + "createdBy": "str", + "createdOn": "2020-02-20 00:00:00", + "description": "str", + "id": "str", + "name": "str", + "permissions": [ + { + "actions": ["str"], + "condition": "str", + "conditionVersion": "str", + "dataActions": ["str"], + "notActions": ["str"], + "notDataActions": ["str"], + } + ], + "roleName": "str", + "type": "str", + "updatedBy": "str", + "updatedOn": "2020-02-20 00:00:00", + }, + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_definitions_list(self, resource_group): + response = self.client.role_definitions.list( + scope="str", + api_version="2022-05-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_definitions_get_by_id(self, resource_group): + response = await self.client.role_definitions.get_by_id( + role_id="str", + api_version="2022-05-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations.py new file mode 100644 index 000000000000..05c890d11492 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilityScheduleInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_instances_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedule_instances.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_instances_get(self, resource_group): + response = self.client.role_eligibility_schedule_instances.get( + scope="str", + role_eligibility_schedule_instance_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations_async.py new file mode 100644 index 000000000000..9437bac03661 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_instances_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilityScheduleInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_instances_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedule_instances.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_instances_get(self, resource_group): + response = await self.client.role_eligibility_schedule_instances.get( + scope="str", + role_eligibility_schedule_instance_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations.py new file mode 100644 index 000000000000..7edcc3ccbb36 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilityScheduleRequestsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_requests_create(self, resource_group): + response = self.client.role_eligibility_schedule_requests.create( + scope="str", + role_eligibility_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleEligibilityScheduleId": "str", + "targetRoleEligibilityScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_requests_get(self, resource_group): + response = self.client.role_eligibility_schedule_requests.get( + scope="str", + role_eligibility_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_requests_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedule_requests.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_requests_cancel(self, resource_group): + response = self.client.role_eligibility_schedule_requests.cancel( + scope="str", + role_eligibility_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedule_requests_validate(self, resource_group): + response = self.client.role_eligibility_schedule_requests.validate( + scope="str", + role_eligibility_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleEligibilityScheduleId": "str", + "targetRoleEligibilityScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations_async.py new file mode 100644 index 000000000000..cfb30281dbb7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedule_requests_operations_async.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilityScheduleRequestsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_requests_create(self, resource_group): + response = await self.client.role_eligibility_schedule_requests.create( + scope="str", + role_eligibility_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleEligibilityScheduleId": "str", + "targetRoleEligibilityScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_requests_get(self, resource_group): + response = await self.client.role_eligibility_schedule_requests.get( + scope="str", + role_eligibility_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_requests_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedule_requests.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_requests_cancel(self, resource_group): + response = await self.client.role_eligibility_schedule_requests.cancel( + scope="str", + role_eligibility_schedule_request_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedule_requests_validate(self, resource_group): + response = await self.client.role_eligibility_schedule_requests.validate( + scope="str", + role_eligibility_schedule_request_name="str", + parameters={ + "approvalId": "str", + "condition": "str", + "conditionVersion": "str", + "createdOn": "2020-02-20 00:00:00", + "expandedProperties": { + "principal": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "id": "str", + "justification": "str", + "name": "str", + "principalId": "str", + "principalType": "str", + "requestType": "str", + "requestorId": "str", + "roleDefinitionId": "str", + "scheduleInfo": { + "expiration": {"duration": "str", "endDateTime": "2020-02-20 00:00:00", "type": "str"}, + "startDateTime": "2020-02-20 00:00:00", + }, + "scope": "str", + "status": "str", + "targetRoleEligibilityScheduleId": "str", + "targetRoleEligibilityScheduleInstanceId": "str", + "ticketInfo": {"ticketNumber": "str", "ticketSystem": "str"}, + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations.py new file mode 100644 index 000000000000..445ef675d3b1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilitySchedulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedules_get(self, resource_group): + response = self.client.role_eligibility_schedules.get( + scope="str", + role_eligibility_schedule_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_eligibility_schedules_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedules.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations_async.py new file mode 100644 index 000000000000..2663fab56898 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_eligibility_schedules_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleEligibilitySchedulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedules_get(self, resource_group): + response = await self.client.role_eligibility_schedules.get( + scope="str", + role_eligibility_schedule_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_eligibility_schedules_list_for_scope(self, resource_group): + response = self.client.role_eligibility_schedules.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations.py new file mode 100644 index 000000000000..04677cdb6ad8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations.py @@ -0,0 +1,80 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleManagementPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policies_get(self, resource_group): + response = self.client.role_management_policies.get( + scope="str", + role_management_policy_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policies_update(self, resource_group): + response = self.client.role_management_policies.update( + scope="str", + role_management_policy_name="str", + parameters={ + "description": "str", + "displayName": "str", + "effectiveRules": ["role_management_policy_rule"], + "id": "str", + "isOrganizationDefault": bool, + "lastModifiedBy": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "lastModifiedDateTime": "2020-02-20 00:00:00", + "name": "str", + "policyProperties": {"scope": {"displayName": "str", "id": "str", "type": "str"}}, + "rules": ["role_management_policy_rule"], + "scope": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policies_delete(self, resource_group): + response = self.client.role_management_policies.delete( + scope="str", + role_management_policy_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policies_list_for_scope(self, resource_group): + response = self.client.role_management_policies.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations_async.py new file mode 100644 index 000000000000..f81577d38fcc --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policies_operations_async.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleManagementPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policies_get(self, resource_group): + response = await self.client.role_management_policies.get( + scope="str", + role_management_policy_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policies_update(self, resource_group): + response = await self.client.role_management_policies.update( + scope="str", + role_management_policy_name="str", + parameters={ + "description": "str", + "displayName": "str", + "effectiveRules": ["role_management_policy_rule"], + "id": "str", + "isOrganizationDefault": bool, + "lastModifiedBy": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "lastModifiedDateTime": "2020-02-20 00:00:00", + "name": "str", + "policyProperties": {"scope": {"displayName": "str", "id": "str", "type": "str"}}, + "rules": ["role_management_policy_rule"], + "scope": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policies_delete(self, resource_group): + response = await self.client.role_management_policies.delete( + scope="str", + role_management_policy_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policies_list_for_scope(self, resource_group): + response = self.client.role_management_policies.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations.py new file mode 100644 index 000000000000..331258480784 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleManagementPolicyAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policy_assignments_get(self, resource_group): + response = self.client.role_management_policy_assignments.get( + scope="str", + role_management_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policy_assignments_create(self, resource_group): + response = self.client.role_management_policy_assignments.create( + scope="str", + role_management_policy_assignment_name="str", + parameters={ + "effectiveRules": ["role_management_policy_rule"], + "id": "str", + "name": "str", + "policyAssignmentProperties": { + "policy": { + "id": "str", + "lastModifiedBy": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "lastModifiedDateTime": "2020-02-20 00:00:00", + }, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "policyId": "str", + "roleDefinitionId": "str", + "scope": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policy_assignments_delete(self, resource_group): + response = self.client.role_management_policy_assignments.delete( + scope="str", + role_management_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_role_management_policy_assignments_list_for_scope(self, resource_group): + response = self.client.role_management_policy_assignments.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations_async.py new file mode 100644 index 000000000000..7dc9ee57e6cb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_role_management_policy_assignments_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementRoleManagementPolicyAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policy_assignments_get(self, resource_group): + response = await self.client.role_management_policy_assignments.get( + scope="str", + role_management_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policy_assignments_create(self, resource_group): + response = await self.client.role_management_policy_assignments.create( + scope="str", + role_management_policy_assignment_name="str", + parameters={ + "effectiveRules": ["role_management_policy_rule"], + "id": "str", + "name": "str", + "policyAssignmentProperties": { + "policy": { + "id": "str", + "lastModifiedBy": {"displayName": "str", "email": "str", "id": "str", "type": "str"}, + "lastModifiedDateTime": "2020-02-20 00:00:00", + }, + "roleDefinition": {"displayName": "str", "id": "str", "type": "str"}, + "scope": {"displayName": "str", "id": "str", "type": "str"}, + }, + "policyId": "str", + "roleDefinitionId": "str", + "scope": "str", + "type": "str", + }, + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policy_assignments_delete(self, resource_group): + response = await self.client.role_management_policy_assignments.delete( + scope="str", + role_management_policy_assignment_name="str", + api_version="2024-09-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_role_management_policy_assignments_list_for_scope(self, resource_group): + response = self.client.role_management_policy_assignments.list_for_scope( + scope="str", + api_version="2024-09-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations.py new file mode 100644 index 000000000000..2bd4fefa784d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewDefaultSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_default_settings_get(self, resource_group): + response = self.client.scope_access_review_default_settings.get( + scope="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_default_settings_put(self, resource_group): + response = self.client.scope_access_review_default_settings.put( + scope="str", + properties={ + "autoApplyDecisionsEnabled": bool, + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "endDate": "2020-02-20 00:00:00", + "instanceDurationInDays": 0, + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "startDate": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations_async.py new file mode 100644 index 000000000000..516d0a9cd35a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_default_settings_operations_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewDefaultSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_default_settings_get(self, resource_group): + response = await self.client.scope_access_review_default_settings.get( + scope="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_default_settings_put(self, resource_group): + response = await self.client.scope_access_review_default_settings.put( + scope="str", + properties={ + "autoApplyDecisionsEnabled": bool, + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "endDate": "2020-02-20 00:00:00", + "instanceDurationInDays": 0, + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "startDate": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations.py new file mode 100644 index 000000000000..6f44b9cd8d95 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionInstanceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definition_instance_generate_download_uri(self, resource_group): + response = self.client.scope_access_review_history_definition_instance.generate_download_uri( + scope="str", + history_definition_id="str", + instance_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations_async.py new file mode 100644 index 000000000000..c1a23c822e1a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instance_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionInstanceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definition_instance_generate_download_uri(self, resource_group): + response = await self.client.scope_access_review_history_definition_instance.generate_download_uri( + scope="str", + history_definition_id="str", + instance_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations.py new file mode 100644 index 000000000000..03d54b8ab734 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definition_instances_list(self, resource_group): + response = self.client.scope_access_review_history_definition_instances.list( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations_async.py new file mode 100644 index 000000000000..e31c215648fd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_instances_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definition_instances_list(self, resource_group): + response = self.client.scope_access_review_history_definition_instances.list( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations.py new file mode 100644 index 000000000000..234e12c69bd2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definition_create(self, resource_group): + response = self.client.scope_access_review_history_definition.create( + scope="str", + history_definition_id="str", + properties={ + "createdDateTime": "2020-02-20 00:00:00", + "decisions": ["str"], + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "instances": [ + { + "displayName": "str", + "downloadUri": "str", + "expiration": "2020-02-20 00:00:00", + "fulfilledDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "runDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "scopes": [ + { + "assignmentState": "str", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "principalType": "str", + "resourceId": "str", + "roleDefinitionId": "str", + } + ], + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definition_delete_by_id(self, resource_group): + response = self.client.scope_access_review_history_definition.delete_by_id( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations_async.py new file mode 100644 index 000000000000..10d93148f416 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definition_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definition_create(self, resource_group): + response = await self.client.scope_access_review_history_definition.create( + scope="str", + history_definition_id="str", + properties={ + "createdDateTime": "2020-02-20 00:00:00", + "decisions": ["str"], + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "instances": [ + { + "displayName": "str", + "downloadUri": "str", + "expiration": "2020-02-20 00:00:00", + "fulfilledDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "runDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "reviewHistoryPeriodEndDateTime": "2020-02-20 00:00:00", + "reviewHistoryPeriodStartDateTime": "2020-02-20 00:00:00", + "scopes": [ + { + "assignmentState": "str", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "principalType": "str", + "resourceId": "str", + "roleDefinitionId": "str", + } + ], + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definition_delete_by_id(self, resource_group): + response = await self.client.scope_access_review_history_definition.delete_by_id( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations.py new file mode 100644 index 000000000000..12701b8b8b39 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definitions_list(self, resource_group): + response = self.client.scope_access_review_history_definitions.list( + scope="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_history_definitions_get_by_id(self, resource_group): + response = self.client.scope_access_review_history_definitions.get_by_id( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations_async.py new file mode 100644 index 000000000000..c33cf8c576f7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_history_definitions_operations_async.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewHistoryDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definitions_list(self, resource_group): + response = self.client.scope_access_review_history_definitions.list( + scope="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_history_definitions_get_by_id(self, resource_group): + response = await self.client.scope_access_review_history_definitions.get_by_id( + scope="str", + history_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..26a0e9d4ddcd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceContactedReviewersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.scope_access_review_instance_contacted_reviewers.list( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations_async.py new file mode 100644 index 000000000000..5094b24ac4b3 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_contacted_reviewers_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceContactedReviewersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.scope_access_review_instance_contacted_reviewers.list( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..4cca4f38bcfe --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceDecisionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_decisions_list(self, resource_group): + response = self.client.scope_access_review_instance_decisions.list( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations_async.py new file mode 100644 index 000000000000..1ad5a12f52bf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_decisions_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceDecisionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_decisions_list(self, resource_group): + response = self.client.scope_access_review_instance_decisions.list( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations.py new file mode 100644 index 000000000000..cacf7682df2a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_stop(self, resource_group): + response = self.client.scope_access_review_instance.stop( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_record_all_decisions(self, resource_group): + response = self.client.scope_access_review_instance.record_all_decisions( + scope="str", + schedule_definition_id="str", + id="str", + properties={"decision": "str", "justification": "str", "principalId": "str", "resourceId": "str"}, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_reset_decisions(self, resource_group): + response = self.client.scope_access_review_instance.reset_decisions( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_apply_decisions(self, resource_group): + response = self.client.scope_access_review_instance.apply_decisions( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instance_send_reminders(self, resource_group): + response = self.client.scope_access_review_instance.send_reminders( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations_async.py new file mode 100644 index 000000000000..045b6dfc316b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instance_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstanceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_stop(self, resource_group): + response = await self.client.scope_access_review_instance.stop( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_record_all_decisions(self, resource_group): + response = await self.client.scope_access_review_instance.record_all_decisions( + scope="str", + schedule_definition_id="str", + id="str", + properties={"decision": "str", "justification": "str", "principalId": "str", "resourceId": "str"}, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_reset_decisions(self, resource_group): + response = await self.client.scope_access_review_instance.reset_decisions( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_apply_decisions(self, resource_group): + response = await self.client.scope_access_review_instance.apply_decisions( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instance_send_reminders(self, resource_group): + response = await self.client.scope_access_review_instance.send_reminders( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations.py new file mode 100644 index 000000000000..d1336dedf941 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instances_list(self, resource_group): + response = self.client.scope_access_review_instances.list( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instances_get_by_id(self, resource_group): + response = self.client.scope_access_review_instances.get_by_id( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_instances_create(self, resource_group): + response = self.client.scope_access_review_instances.create( + scope="str", + schedule_definition_id="str", + id="str", + properties={ + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations_async.py new file mode 100644 index 000000000000..a64d703e14f7 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_instances_operations_async.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instances_list(self, resource_group): + response = self.client.scope_access_review_instances.list( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instances_get_by_id(self, resource_group): + response = await self.client.scope_access_review_instances.get_by_id( + scope="str", + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_instances_create(self, resource_group): + response = await self.client.scope_access_review_instances.create( + scope="str", + schedule_definition_id="str", + id="str", + properties={ + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..f2ceebc7d7c1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewScheduleDefinitionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_schedule_definitions_list(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.list( + scope="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_schedule_definitions_get_by_id(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.get_by_id( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_schedule_definitions_delete_by_id(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.delete_by_id( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_schedule_definitions_create_or_update_by_id(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.create_or_update_by_id( + scope="str", + schedule_definition_id="str", + properties={ + "assignmentState": "str", + "autoApplyDecisionsEnabled": bool, + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "descriptionForAdmins": "str", + "descriptionForReviewers": "str", + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "instanceDurationInDays": 0, + "instances": [ + { + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "resourceId": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "roleDefinitionId": "str", + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_scope_access_review_schedule_definitions_stop(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.stop( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations_async.py new file mode 100644 index 000000000000..02d364d59810 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_scope_access_review_schedule_definitions_operations_async.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementScopeAccessReviewScheduleDefinitionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_schedule_definitions_list(self, resource_group): + response = self.client.scope_access_review_schedule_definitions.list( + scope="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_schedule_definitions_get_by_id(self, resource_group): + response = await self.client.scope_access_review_schedule_definitions.get_by_id( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_schedule_definitions_delete_by_id(self, resource_group): + response = await self.client.scope_access_review_schedule_definitions.delete_by_id( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_schedule_definitions_create_or_update_by_id(self, resource_group): + response = await self.client.scope_access_review_schedule_definitions.create_or_update_by_id( + scope="str", + schedule_definition_id="str", + properties={ + "assignmentState": "str", + "autoApplyDecisionsEnabled": bool, + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "defaultDecision": "str", + "defaultDecisionEnabled": bool, + "descriptionForAdmins": "str", + "descriptionForReviewers": "str", + "displayName": "str", + "endDate": "2020-02-20 00:00:00", + "excludeResourceId": "str", + "excludeRoleDefinitionId": "str", + "expandNestedMemberships": bool, + "inactiveDuration": "1 day, 0:00:00", + "includeAccessBelowResource": bool, + "includeInheritedAccess": bool, + "instanceDurationInDays": 0, + "instances": [ + { + "backupReviewers": [{"principalId": "str", "principalType": "str"}], + "endDateTime": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "startDateTime": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + } + ], + "interval": 0, + "justificationRequiredOnApproval": bool, + "mailNotificationsEnabled": bool, + "numberOfOccurrences": 0, + "principalId": "str", + "principalName": "str", + "principalType": "str", + "recommendationLookBackDuration": "1 day, 0:00:00", + "recommendationsEnabled": bool, + "reminderNotificationsEnabled": bool, + "resourceId": "str", + "reviewers": [{"principalId": "str", "principalType": "str"}], + "reviewersType": "str", + "roleDefinitionId": "str", + "startDate": "2020-02-20 00:00:00", + "status": "str", + "type": "str", + "userPrincipalName": "str", + }, + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_scope_access_review_schedule_definitions_stop(self, resource_group): + response = await self.client.scope_access_review_schedule_definitions.stop( + scope="str", + schedule_definition_id="str", + api_version="2021-12-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..b186e2e5868b --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementTenantLevelAccessReviewInstanceContactedReviewersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tenant_level_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.tenant_level_access_review_instance_contacted_reviewers.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations_async.py b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations_async.py new file mode 100644 index 000000000000..e7124d368bf4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/generated_tests/test_authorization_management_tenant_level_access_review_instance_contacted_reviewers_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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 pytest +from azure.mgmt.authorization.aio import AuthorizationManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAuthorizationManagementTenantLevelAccessReviewInstanceContactedReviewersOperationsAsync( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(AuthorizationManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tenant_level_access_review_instance_contacted_reviewers_list(self, resource_group): + response = self.client.tenant_level_access_review_instance_contacted_reviewers.list( + schedule_definition_id="str", + id="str", + api_version="2021-12-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/authorization/azure-mgmt-authorization/sdk_packaging.toml b/sdk/authorization/azure-mgmt-authorization/sdk_packaging.toml index 3e101585de58..56701b014dbe 100644 --- a/sdk/authorization/azure-mgmt-authorization/sdk_packaging.toml +++ b/sdk/authorization/azure-mgmt-authorization/sdk_packaging.toml @@ -2,6 +2,6 @@ package_name = "azure-mgmt-authorization" package_pprint_name = "Authorization Management" package_doc_id = "authorization" -is_stable = true +is_stable = false sample_link = "" title = "AuthorizationManagementClient" diff --git a/sdk/authorization/azure-mgmt-authorization/setup.py b/sdk/authorization/azure-mgmt-authorization/setup.py index 5f47308c560a..a6ceda3fa32a 100644 --- a/sdk/authorization/azure-mgmt-authorization/setup.py +++ b/sdk/authorization/azure-mgmt-authorization/setup.py @@ -49,15 +49,14 @@ url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +73,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.7", + python_requires=">=3.9", )